Completed
Push — master ( 376d77...59bfb2 )
by
unknown
01:07
created

test_hook_with_extension()   A

Complexity

Conditions 3

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 21
rs 9.3142
1
# -*- coding: utf-8 -*-
2
3
import os
4
import codecs
5
6
import pytest
7
8
from cookiecutter import main
9
10
11
@pytest.fixture(params=[
12
    'custom-extension-pre',
13
    'custom-extension-post',
14
], ids=[
15
    'pre_gen_hook',
16
    'post_gen_hook',
17
])
18
def template(request):
19
    return 'tests/test-extensions/' + request.param
20
21
22
@pytest.fixture
23
def output_dir(tmpdir):
24
    return str(tmpdir.mkdir('hello'))
25
26
27
@pytest.fixture(autouse=True)
28
def modify_syspath(monkeypatch):
29
    # Make sure that the custom extension can be loaded
30
    monkeypatch.syspath_prepend(
31
        'tests/test-extensions/hello_extension'
32
    )
33
34
35
@pytest.mark.xfail(
36
    reason='issue #850',
37
    strict=True,
38
)
39
def test_hook_with_extension(template, output_dir):
40
    project_dir = main.cookiecutter(
41
        template,
42
        no_input=True,
43
        output_dir=output_dir,
44
        extra_context={
45
            'project_slug': 'foobar',
46
            'name': 'Cookiemonster',
47
        },
48
    )
49
50
    readme_file = os.path.join(project_dir, 'README.rst')
51
52
    with codecs.open(readme_file, encoding='utf8') as f:
53
        readme = f.read().strip()
54
55
    assert readme == 'Hello Cookiemonster!'
56