@pytest.fixture(scope='module', params=VC_BRANCH.keys())
def test_repo(request):
 vc = request.param
 temp_dir = tempfile.mkdtemp()
 os.chdir(temp_dir)
 try:
  sp.call([vc, 'init'])
 except FileNotFoundError:
  pytest.skip('cannot find {} executable'.format(vc))
 if (vc == 'git'):
  with open('test-file', 'w'):
   pass
  sp.call(['git', 'add', 'test-file'])
  sp.call(['git', 'commit', '-m', 'test commit'])
 return {'name': vc, 'dir': temp_dir}

@ pytest . fixture ( scope = 'module' , params = VC_BRANCH . keys ( ) ) def test_repo ( request ) : vc = request . param temp_dir = tempfile . mkdtemp ( ) os . chdir ( temp_dir ) try : sp . call ( [ vc , 'init' ] ) except FileNotFoundError : pytest . skip ( 'cannot find {} executable' . format ( vc ) ) if ( vc == 'git' ) : with open ( 'test-file' , 'w' ) : pass sp . call ( [ 'git' , 'add' , 'test-file' ] ) sp . call ( [ 'git' , 'commit' , '-m' , 'test commit' ] ) return { 'name' : vc , 'dir' : temp_dir }
return a dict with vc and a temporary dir that is a repository for testing .