tests.test_environment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_env_should_come_with_jinja2_time_extension() 0 3 1
A test_env_should_raise_for_unknown_extension() 0 11 2
1
# -*- coding: utf-8 -*-
2
3
"""Collection of tests around loading extensions."""
4
5
import pytest
6
7
from cookiecutter.environment import StrictEnvironment
8
from cookiecutter.exceptions import UnknownExtension
9
10
11
def test_env_should_raise_for_unknown_extension():
12
    context = {
13
        'cookiecutter': {
14
            '_extensions': ['foobar']
15
        }
16
    }
17
18
    with pytest.raises(UnknownExtension) as err:
19
        StrictEnvironment(context=context, keep_trailing_newline=True)
20
21
    assert 'Unable to load extension: ' in str(err.value)
22
23
24
def test_env_should_come_with_jinja2_time_extension():
25
    env = StrictEnvironment(keep_trailing_newline=True)
26
    assert 'jinja2_time.jinja2_time.TimeExtension' in env.extensions
27