Code Duplication    Length = 19-23 lines in 2 locations

tests/test_generate_files.py 2 locations

@@ 401-423 (lines=23) @@
398
    assert Path(output_dir).joinpath('testproject').exists()
399
400
401
def test_raise_undefined_variable_dir_name_existing_project(
402
    output_dir, undefined_context
403
):
404
    """Verify correct error raised when directory name cannot be rendered."""
405
    testproj_path = Path(output_dir, 'testproject')
406
    testproj_path.mkdir()
407
408
    with pytest.raises(exceptions.UndefinedVariableInTemplate) as err:
409
        generate.generate_files(
410
            repo_dir='tests/undefined-variable/dir-name/',
411
            output_dir=output_dir,
412
            context=undefined_context,
413
            overwrite_if_exists=True,
414
        )
415
    error = err.value
416
417
    directory = Path('testproject', '{{cookiecutter.foobar}}')
418
    msg = f"Unable to create directory '{directory}'"
419
    assert msg == error.message
420
421
    assert error.context == undefined_context
422
423
    assert testproj_path.exists()
424
425
426
def test_raise_undefined_variable_project_dir(tmp_path):
@@ 334-352 (lines=19) @@
331
    assert not Path(output_dir).joinpath('testproject').exists()
332
333
334
def test_raise_undefined_variable_file_name_existing_project(
335
    output_dir, undefined_context
336
):
337
    """Verify correct error raised when file name cannot be rendered."""
338
    testproj_path = Path(output_dir, 'testproject')
339
    testproj_path.mkdir()
340
341
    with pytest.raises(exceptions.UndefinedVariableInTemplate) as err:
342
        generate.generate_files(
343
            repo_dir='tests/undefined-variable/file-name/',
344
            output_dir=output_dir,
345
            context=undefined_context,
346
            overwrite_if_exists=True,
347
        )
348
    error = err.value
349
    assert "Unable to create file '{{cookiecutter.foobar}}'" == error.message
350
    assert error.context == undefined_context
351
352
    assert testproj_path.exists()
353
354
355
def test_raise_undefined_variable_file_content(output_dir, undefined_context):