|
1 | 1 | import pytest |
2 | | -import os |
3 | | -import sys |
4 | 2 |
|
5 | | -try: |
6 | | - import sh |
7 | | -except ImportError: |
8 | | - pass |
9 | 3 |
|
10 | | - |
11 | | -@pytest.mark.skipif(sys.platform.startswith('win'), |
12 | | - reason='Skipping test with sh-module on Windows') |
13 | 4 | def test_double_quotes_in_name_and_description(cookies): |
14 | | - ctx = {'project_short_description': '"double quotes"', |
15 | | - 'full_name': '"name"name'} |
| 5 | + ctx = { |
| 6 | + "project_short_description": '"double quotes"', |
| 7 | + "full_name": '"name"name' |
| 8 | + } |
16 | 9 | project = cookies.bake(extra_context=ctx) |
17 | 10 |
|
18 | 11 | assert project.exit_code == 0 |
19 | 12 |
|
20 | | - with open(os.path.join(str(project.project), 'setup.py')) as f: |
21 | | - setup = f.read() |
22 | | - print(setup) |
23 | | - |
24 | | - cwd = os.getcwd() |
25 | | - os.chdir(str(project.project)) |
26 | | - |
27 | | - try: |
28 | | - sh.python(['setup.py', 'install']) |
29 | | - except sh.ErrorReturnCode as e: |
30 | | - pytest.fail(e) |
31 | | - finally: |
32 | | - os.chdir(cwd) |
33 | | - |
34 | 13 |
|
35 | | -@pytest.mark.skipif(sys.platform.startswith('win'), |
36 | | - reason='Skipping test with sh-module on Windows') |
37 | 14 | def test_single_quotes_in_name_and_description(cookies): |
38 | | - ctx = {'project_short_description': "'single quotes'", |
39 | | - 'full_name': "Mr. O'Keeffe"} |
| 15 | + ctx = { |
| 16 | + "project_short_description": "'single quotes'", |
| 17 | + "full_name": "Mr. O'Keeffe" |
| 18 | + } |
40 | 19 | project = cookies.bake(extra_context=ctx) |
41 | 20 |
|
42 | 21 | assert project.exit_code == 0 |
43 | 22 |
|
44 | | - with open(os.path.join(str(project.project), 'setup.py')) as f: |
45 | | - setup = f.read() |
46 | | - print(setup) |
47 | | - |
48 | | - cwd = os.getcwd() |
49 | | - os.chdir(str(project.project)) |
50 | | - |
51 | | - try: |
52 | | - sh.python(['setup.py', 'install']) |
53 | | - except sh.ErrorReturnCode as e: |
54 | | - pytest.fail(e) |
55 | | - finally: |
56 | | - os.chdir(cwd) |
57 | | - |
58 | 23 |
|
59 | | -@pytest.mark.skipif(sys.platform.startswith('win'), |
60 | | - reason='Skipping test with sh-module on Windows') |
61 | 24 | def test_dash_in_project_slug(cookies): |
62 | | - ctx = {'project_slug': "my-package"} |
| 25 | + ctx = { |
| 26 | + "project_slug": "my-package" |
| 27 | + } |
63 | 28 | project = cookies.bake(extra_context=ctx) |
64 | 29 |
|
65 | 30 | assert project.exit_code == 0 |
66 | 31 |
|
67 | | - with open(os.path.join(str(project.project), 'setup.py')) as f: |
68 | | - setup = f.read() |
69 | | - print(setup) |
70 | 32 |
|
71 | | - cwd = os.getcwd() |
72 | | - os.chdir(str(project.project)) |
73 | | - |
74 | | - try: |
75 | | - sh.python(['setup.py', 'install']) |
76 | | - sh.python(['setup.py', 'build_sphinx']) |
77 | | - except sh.ErrorReturnCode as e: |
78 | | - pytest.fail(e) |
79 | | - finally: |
80 | | - os.chdir(cwd) |
81 | | - |
82 | | - |
83 | | -@pytest.mark.skipif(sys.platform.startswith('win'), |
84 | | - reason='Skipping test with sh-module on Windows') |
85 | 33 | def test_space_in_project_slug(cookies): |
86 | | - ctx = {'project_slug': "my package"} |
| 34 | + ctx = { |
| 35 | + "project_slug": "my package" |
| 36 | + } |
87 | 37 | project = cookies.bake(extra_context=ctx) |
88 | 38 |
|
89 | 39 | assert project.exit_code == 0 |
90 | | - |
91 | | - with open(os.path.join(str(project.project), 'setup.py')) as f: |
92 | | - setup = f.read() |
93 | | - print(setup) |
94 | | - |
95 | | - cwd = os.getcwd() |
96 | | - os.chdir(str(project.project)) |
97 | | - |
98 | | - try: |
99 | | - sh.python(['setup.py', 'install']) |
100 | | - sh.python(['setup.py', 'build_sphinx']) |
101 | | - except sh.ErrorReturnCode as e: |
102 | | - pytest.fail(e) |
103 | | - finally: |
104 | | - os.chdir(cwd) |
0 commit comments