Total Complexity | 3 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Collection of tests around loading extensions.""" |
||
2 | import pytest |
||
3 | |||
4 | from cookiecutter.environment import StrictEnvironment |
||
5 | from cookiecutter.exceptions import UnknownExtension |
||
6 | |||
7 | |||
8 | def test_env_should_raise_for_unknown_extension(): |
||
9 | """Test should raise if extension not installed in system.""" |
||
10 | context = {'cookiecutter': {'_extensions': ['foobar']}} |
||
11 | |||
12 | with pytest.raises(UnknownExtension) as err: |
||
13 | StrictEnvironment(context=context, keep_trailing_newline=True) |
||
14 | |||
15 | assert 'Unable to load extension: ' in str(err.value) |
||
16 | |||
17 | |||
18 | def test_env_should_come_with_default_extensions(): |
||
19 | """Verify default extensions loaded with StrictEnvironment.""" |
||
20 | env = StrictEnvironment(keep_trailing_newline=True) |
||
21 | assert 'jinja2_time.jinja2_time.TimeExtension' in env.extensions |
||
22 | assert 'cookiecutter.extensions.JsonifyExtension' in env.extensions |
||
23 | assert 'cookiecutter.extensions.RandomStringExtension' in env.extensions |
||
24 | assert 'cookiecutter.extensions.SlugifyExtension' in env.extensions |
||
25 | assert 'cookiecutter.extensions.UUIDExtension' in env.extensions |
||
26 |