1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
""" |
5
|
|
|
test_cookiecutter_repo_arg |
6
|
|
|
-------------------------- |
7
|
|
|
|
8
|
|
|
Tests formerly known from a unittest residing in test_main.py named |
9
|
|
|
TestCookiecutterRepoArg.test_cookiecutter_git |
10
|
|
|
TestCookiecutterRepoArg.test_cookiecutter_mercurial |
11
|
|
|
""" |
12
|
|
|
|
13
|
|
|
from __future__ import unicode_literals |
14
|
|
|
import os |
15
|
|
|
import pytest |
16
|
|
|
|
17
|
|
|
from cookiecutter import main, utils |
18
|
|
|
from tests.skipif_markers import skipif_no_network |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
@pytest.fixture(scope='function') |
22
|
|
|
def remove_additional_folders(request): |
23
|
|
|
""" |
24
|
|
|
Remove some special folders which are created by the tests. |
25
|
|
|
""" |
26
|
|
|
def fin_remove_additional_folders(): |
27
|
|
|
if os.path.isdir('cookiecutter-pypackage'): |
28
|
|
|
utils.rmtree('cookiecutter-pypackage') |
29
|
|
|
if os.path.isdir('python_boilerplate'): |
30
|
|
|
utils.rmtree('python_boilerplate') |
31
|
|
|
if os.path.isdir('cookiecutter-trytonmodule'): |
32
|
|
|
utils.rmtree('cookiecutter-trytonmodule') |
33
|
|
|
if os.path.isdir('module_name'): |
34
|
|
|
utils.rmtree('module_name') |
35
|
|
|
request.addfinalizer(fin_remove_additional_folders) |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
@skipif_no_network |
39
|
|
|
@pytest.mark.usefixtures('clean_system', 'remove_additional_folders') |
40
|
|
|
def test_cookiecutter_git(): |
41
|
|
|
main.cookiecutter( |
42
|
|
|
'https://github.com/audreyr/cookiecutter-pypackage.git', |
43
|
|
|
no_input=True |
44
|
|
|
) |
45
|
|
|
clone_dir = os.path.join( |
46
|
|
|
os.path.expanduser('~/.cookiecutters'), |
47
|
|
|
'cookiecutter-pypackage' |
48
|
|
|
) |
49
|
|
|
assert os.path.exists(clone_dir) |
50
|
|
|
assert os.path.isdir('python_boilerplate') |
51
|
|
|
assert os.path.isfile('python_boilerplate/README.rst') |
52
|
|
|
assert os.path.exists('python_boilerplate/setup.py') |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
@skipif_no_network |
56
|
|
|
@pytest.mark.usefixtures('clean_system', 'remove_additional_folders') |
57
|
|
|
def test_cookiecutter_mercurial(monkeypatch): |
58
|
|
|
monkeypatch.setattr( |
59
|
|
|
'cookiecutter.prompt.read_user_variable', |
60
|
|
|
lambda var, default: default |
61
|
|
|
) |
62
|
|
|
|
63
|
|
|
main.cookiecutter('https://bitbucket.org/pokoli/cookiecutter-trytonmodule') |
64
|
|
|
clone_dir = os.path.join( |
65
|
|
|
os.path.expanduser('~/.cookiecutters'), |
66
|
|
|
'cookiecutter-trytonmodule' |
67
|
|
|
) |
68
|
|
|
assert os.path.exists(clone_dir) |
69
|
|
|
assert os.path.isdir('module_name') |
70
|
|
|
assert os.path.isfile('module_name/README') |
71
|
|
|
assert os.path.exists('module_name/setup.py') |
72
|
|
|
|