Total Complexity | 3 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |