forked from cookiecutter/cookiecutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_more_cookiecutters.py
72 lines (58 loc) · 2.16 KB
/
test_more_cookiecutters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_more_cookiecutters
-----------------------
Test formerly known from a unittest residing in test_examples.py named
TestGitBranch.test_branch
TestExamplesRepoArg.test_cookiecutter_pypackage_git
"""
from __future__ import unicode_literals
import os
import sys
import subprocess
import pytest
from cookiecutter import config, utils
from tests.skipif_markers import skipif_travis, skipif_no_network
@pytest.fixture(scope='function')
def remove_additional_dirs(request):
"""
Remove special directories which are creating during the tests.
"""
def fin_remove_additional_dirs():
with utils.work_in(config.DEFAULT_CONFIG['cookiecutters_dir']):
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
if os.path.isdir('python_boilerplate'):
utils.rmtree('python_boilerplate')
request.addfinalizer(fin_remove_additional_dirs)
@skipif_travis
@skipif_no_network
@pytest.mark.usefixtures('clean_system', 'remove_additional_dirs')
def test_git_branch():
pypackage_git = 'https://github.com/audreyr/cookiecutter-pypackage.git'
proc = subprocess.Popen(
'{0} -m cookiecutter.cli -c console-script {1}'.format(sys.executable,
pypackage_git),
stdin=subprocess.PIPE,
shell=True
)
# Just skip all the prompts
proc.communicate(input=b'\n\n\n\n\n\n\n\n\n\n\n\n')
assert os.path.isfile('boilerplate/README.rst')
assert os.path.isfile('boilerplate/boilerplate/main.py')
@skipif_travis
@skipif_no_network
@pytest.mark.usefixtures('clean_system', 'remove_additional_dirs')
def test_cookiecutter_pypackage_git():
proc = subprocess.Popen(
'{0} -m cookiecutter.cli https://github.com/audreyr/'
'cookiecutter-pypackage.git'.format(sys.executable),
stdin=subprocess.PIPE,
shell=True
)
# Just skip all the prompts
proc.communicate(input=b'\n\n\n\n\n\n\n\n\n\n\n\n')
assert os.path.isfile('python_boilerplate/README.rst')