Skip to content

Commit e3b079f

Browse files
committed
Move cookiecutter_template fixture to conftest.py
1 parent 0245ba0 commit e3b079f

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

tests/conftest.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import collections
4+
import json
5+
6+
import pytest
7+
18
pytest_plugins = 'pytester'
9+
10+
11+
@pytest.fixture(name='cookiecutter_template')
12+
def fixture_cookiecutter_template(tmpdir):
13+
template = tmpdir.ensure('cookiecutter-template', dir=True)
14+
15+
template_config = collections.OrderedDict([
16+
('repo_name', 'foobar'),
17+
('short_description', 'Test Project'),
18+
])
19+
template.join('cookiecutter.json').write(json.dumps(template_config))
20+
21+
template_readme = '\n'.join([
22+
'{{cookiecutter.repo_name}}',
23+
'{% for _ in cookiecutter.repo_name %}={% endfor %}',
24+
'{{cookiecutter.short_description}}',
25+
])
26+
27+
repo = template.ensure('{{cookiecutter.repo_name}}', dir=True)
28+
repo.join('README.rst').write(template_readme)
29+
30+
return template

tests/test_cookies.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import json
4-
import collections
5-
64
import pytest
75

86

@@ -30,28 +28,6 @@ def test_valid_fixture(cookies):
3028
assert result.ret == 0
3129

3230

33-
@pytest.fixture
34-
def cookiecutter_template(tmpdir):
35-
template = tmpdir.ensure('cookiecutter-template', dir=True)
36-
37-
template_config = collections.OrderedDict([
38-
('repo_name', 'foobar'),
39-
('short_description', 'Test Project'),
40-
])
41-
template.join('cookiecutter.json').write(json.dumps(template_config))
42-
43-
template_readme = '\n'.join([
44-
'{{cookiecutter.repo_name}}',
45-
'{% for _ in cookiecutter.repo_name %}={% endfor %}',
46-
'{{cookiecutter.short_description}}',
47-
])
48-
49-
repo = template.ensure('{{cookiecutter.repo_name}}', dir=True)
50-
repo.join('README.rst').write(template_readme)
51-
52-
return template
53-
54-
5531
def test_cookies_bake_with_template_kwarg(testdir, cookiecutter_template):
5632
"""bake accepts a template kwarg."""
5733
testdir.makepyfile("""

0 commit comments

Comments
 (0)