@@ 379-400 (lines=22) @@ | ||
376 | assert not output_dir.join('testproject').exists() |
|
377 | ||
378 | ||
379 | def test_raise_undefined_variable_dir_name_existing_project(tmpdir, undefined_context): |
|
380 | """Verify correct error raised when directory name cannot be rendered.""" |
|
381 | output_dir = tmpdir.mkdir('output') |
|
382 | ||
383 | output_dir.join('testproject').mkdir() |
|
384 | ||
385 | with pytest.raises(exceptions.UndefinedVariableInTemplate) as err: |
|
386 | generate.generate_files( |
|
387 | repo_dir='tests/undefined-variable/dir-name/', |
|
388 | output_dir=str(output_dir), |
|
389 | context=undefined_context, |
|
390 | overwrite_if_exists=True, |
|
391 | ) |
|
392 | error = err.value |
|
393 | ||
394 | directory = os.path.join('testproject', '{{cookiecutter.foobar}}') |
|
395 | msg = "Unable to create directory '{}'".format(directory) |
|
396 | assert msg == error.message |
|
397 | ||
398 | assert error.context == undefined_context |
|
399 | ||
400 | assert output_dir.join('testproject').exists() |
|
401 | ||
402 | ||
403 | def test_raise_undefined_variable_project_dir(tmp_path): |
|
@@ 358-375 (lines=18) @@ | ||
355 | assert not output_dir.join('testproject').exists() |
|
356 | ||
357 | ||
358 | def test_raise_undefined_variable_dir_name(tmpdir, undefined_context): |
|
359 | """Verify correct error raised when directory name cannot be rendered.""" |
|
360 | output_dir = tmpdir.mkdir('output') |
|
361 | ||
362 | with pytest.raises(exceptions.UndefinedVariableInTemplate) as err: |
|
363 | generate.generate_files( |
|
364 | repo_dir='tests/undefined-variable/dir-name/', |
|
365 | output_dir=str(output_dir), |
|
366 | context=undefined_context, |
|
367 | ) |
|
368 | error = err.value |
|
369 | ||
370 | directory = os.path.join('testproject', '{{cookiecutter.foobar}}') |
|
371 | msg = "Unable to create directory '{}'".format(directory) |
|
372 | assert msg == error.message |
|
373 | ||
374 | assert error.context == undefined_context |
|
375 | ||
376 | assert not output_dir.join('testproject').exists() |
|
377 | ||
378 |