Code Duplication    Length = 27-29 lines in 2 locations

tests/vcs/test_clone.py 1 location

@@ 62-90 (lines=29) @@
59
    )
60
61
62
def test_clone_should_abort_if_user_does_not_want_to_reclone(mocker, tmpdir):
63
    """In `clone()`, if user doesn't want to reclone, Cookiecutter should exit
64
    without cloning anything.
65
    """
66
    mocker.patch(
67
        'cookiecutter.vcs.is_vcs_installed',
68
        autospec=True,
69
        return_value=True
70
    )
71
    mocker.patch(
72
        'cookiecutter.vcs.prompt_and_delete',
73
        side_effect=SystemExit,
74
        autospec=True
75
    )
76
    mock_subprocess = mocker.patch(
77
        'cookiecutter.vcs.subprocess.check_output',
78
        autospec=True,
79
    )
80
81
    clone_to_dir = tmpdir.mkdir('clone')
82
83
    # Create repo_dir to trigger prompt_and_delete
84
    clone_to_dir.mkdir('cookiecutter-pytest-plugin')
85
86
    repo_url = 'https://github.com/pytest-dev/cookiecutter-pytest-plugin.git'
87
88
    with pytest.raises(SystemExit):
89
        vcs.clone(repo_url, clone_to_dir=str(clone_to_dir))
90
    assert not mock_subprocess.called
91
92
93
@pytest.mark.parametrize('repo_type, repo_url, repo_name', [

tests/zipfile/test_unzip.py 1 location

@@ 299-325 (lines=27) @@
296
    assert output_dir.startswith(tempfile.gettempdir())
297
298
299
def test_unzip_should_abort_if_no_redownload(mocker, tmpdir):
300
    """In `unzip()`, if user doesn't want to download, Cookiecutter should exit
301
    without cloning anything.
302
    """
303
    mocker.patch(
304
        'cookiecutter.zipfile.prompt_and_delete',
305
        side_effect=SystemExit,
306
        autospec=True
307
    )
308
309
    mock_requests_get = mocker.patch(
310
        'cookiecutter.zipfile.requests.get',
311
        autospec=True,
312
    )
313
314
    clone_to_dir = tmpdir.mkdir('clone')
315
316
    # Create an existing cache of the zipfile
317
    existing_zip = clone_to_dir.join('fake-repo-tmpl.zip')
318
    existing_zip.write('This is an existing zipfile')
319
320
    zipfile_url = 'https://example.com/path/to/fake-repo-tmpl.zip'
321
322
    with pytest.raises(SystemExit):
323
        zipfile.unzip(zipfile_url, is_url=True, clone_to_dir=str(clone_to_dir))
324
325
    assert not mock_requests_get.called
326