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