Total Complexity | 1 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Collection of tests around general exception handling.""" |
||
2 | from jinja2.exceptions import UndefinedError |
||
3 | |||
4 | from cookiecutter import exceptions |
||
5 | |||
6 | |||
7 | def test_undefined_variable_to_str(): |
||
8 | """Verify string representation of errors formatted in expected form.""" |
||
9 | undefined_var_error = exceptions.UndefinedVariableInTemplate( |
||
10 | 'Beautiful is better than ugly', |
||
11 | UndefinedError('Errors should never pass silently'), |
||
12 | {'cookiecutter': {'foo': 'bar'}}, |
||
13 | ) |
||
14 | |||
15 | expected_str = ( |
||
16 | "Beautiful is better than ugly. " |
||
17 | "Error message: Errors should never pass silently. " |
||
18 | "Context: {'cookiecutter': {'foo': 'bar'}}" |
||
19 | ) |
||
20 | |||
21 | assert str(undefined_var_error) == expected_str |
||
22 |