Completed
Push — master ( 01b6e4...5ea952 )
by Andrey
33s queued 13s
created

tests.test_templates   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 21
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A output_dir() 0 4 1
A test_build_templates() 0 22 2
1
"""
2
test_custom_extension_in_hooks.
3
4
Tests to ensure custom cookiecutter extensions are properly made available to
5
pre- and post-gen hooks.
6
"""
7
import codecs
8
import os
9
10
import pytest
11
12
from cookiecutter import main
13
14
15
@pytest.fixture
16
def output_dir(tmpdir):
17
    """Fixture. Create and return custom temp directory for test."""
18
    return str(tmpdir.mkdir('templates'))
19
20
21
@pytest.mark.parametrize("template", ["include", "no-templates", "extends", "super"])
22
def test_build_templates(template, output_dir):
23
    """
24
    Verify Templates Design keywords.
25
26
    no-templates is a compatibility tests for repo without `templates` directory
27
    """
28
    project_dir = main.cookiecutter(
29
        f'tests/test-templates/{template}',
30
        no_input=True,
31
        output_dir=output_dir,
32
    )
33
34
    readme_file = os.path.join(project_dir, 'requirements.txt')
35
36
    with codecs.open(readme_file, encoding='utf8') as f:
37
        readme = f.read().splitlines()
38
39
    assert readme == [
40
        "pip==19.2.3",
41
        "Click==7.0",
42
        "pytest==4.6.5",
43
    ]
44