@pytest.mark.parametrize('repo_type, repo_url, repo_name', [('git', 'https://github.com/hello/world.git', 'world'), ('hg', 'https://bitbucket.org/foo/bar', 'bar')])
def test_clone_should_invoke_vcs_command(mocker, clone_dir, repo_type, repo_url, repo_name):
 mocker.patch('cookiecutter.vcs.is_vcs_installed', autospec=True, return_value=True)
 mock_subprocess = mocker.patch('cookiecutter.vcs.subprocess.check_output', autospec=True)
 expected_repo_dir = os.path.normpath(os.path.join(clone_dir, repo_name))
 branch = 'foobar'
 repo_dir = vcs.clone(repo_url, checkout=branch, clone_to_dir=clone_dir, no_input=True)
 assert (repo_dir == expected_repo_dir)
 mock_subprocess.assert_any_call([repo_type, 'clone', repo_url], cwd=clone_dir, stderr=subprocess.STDOUT)
 mock_subprocess.assert_any_call([repo_type, 'checkout', branch], cwd=expected_repo_dir, stderr=subprocess.STDOUT)

@ pytest . mark . parametrize ( 'repo_type, repo_url, repo_name' , [ ( 'git' , 'https://github.com/hello/world.git' , 'world' ) , ( 'hg' , 'https://bitbucket.org/foo/bar' , 'bar' ) ] ) def test_clone_should_invoke_vcs_command ( mocker , clone_dir , repo_type , repo_url , repo_name ) : mocker . patch ( 'cookiecutter.vcs.is_vcs_installed' , autospec = True , return_value = True ) mock_subprocess = mocker . patch ( 'cookiecutter.vcs.subprocess.check_output' , autospec = True ) expected_repo_dir = os . path . normpath ( os . path . join ( clone_dir , repo_name ) ) branch = 'foobar' repo_dir = vcs . clone ( repo_url , checkout = branch , clone_to_dir = clone_dir , no_input = True ) assert ( repo_dir == expected_repo_dir ) mock_subprocess . assert_any_call ( [ repo_type , 'clone' , repo_url ] , cwd = clone_dir , stderr = subprocess . STDOUT ) mock_subprocess . assert_any_call ( [ repo_type , 'checkout' , branch ] , cwd = expected_repo_dir , stderr = subprocess . STDOUT )
when clone() is called with a git/hg repo .