|
1 | 1 |
|
2 | 2 |
|
3 | 3 |
|
4 |
| -def test_class_scope(ctestdir): |
5 |
| - """ test_a fails, however the scope of the dependency of TestClass::test_b |
6 |
| - causes it to only depend on other tests within its class. test_d failing |
7 |
| - shows that the class scope is actually detecting failures within its own |
8 |
| - class. test_f should skip since test_c within the depends on test_c |
9 |
| - within the class failed """ |
10 |
| - ctestdir.makepyfile(""" |
11 |
| - import pytest |
12 |
| -
|
13 |
| - @pytest.mark.dependency() |
14 |
| - def test_a(): |
15 |
| - assert False |
16 |
| -
|
17 |
| - class TestClass(object): |
18 |
| -
|
19 |
| - @pytest.mark.dependency() |
20 |
| - def test_a(self): |
21 |
| - pass |
22 |
| -
|
23 |
| - @pytest.mark.dependency(scope="class", depends="all") |
24 |
| - def test_b(self): |
25 |
| - pass |
26 |
| -
|
27 |
| - @pytest.mark.dependency() |
28 |
| - def test_c(self): |
29 |
| - assert False |
30 |
| -
|
31 |
| - @pytest.mark.dependency(scope="class", depends="all") |
32 |
| - def test_d(self): |
33 |
| - pass |
34 |
| -
|
35 |
| - @pytest.mark.dependency() |
36 |
| - def test_e(): |
37 |
| - pass |
38 |
| -
|
39 |
| - @pytest.mark.dependency(depends=["TestClass::test_c"]) |
40 |
| - def test_f(): |
41 |
| - pass |
42 |
| -
|
43 |
| - """) |
44 |
| - |
45 |
| - result = ctestdir.runpytest("--verbose", "test_class_scope.py") |
46 |
| - result.assert_outcomes(passed=3, skipped=2, failed=2) |
47 |
| - result.stdout.fnmatch_lines(""" |
48 |
| - *::test_a FAILED |
49 |
| - *::TestClass::test_a PASSED |
50 |
| - *::TestClass::test_b PASSED |
51 |
| - *::TestClass::test_c FAILED |
52 |
| - *::TestClass::test_d SKIPPED |
53 |
| - *::test_e PASSED |
54 |
| - *::test_f SKIPPED |
55 |
| - """) |
56 |
| - |
57 |
| - |
58 | 4 | def test_session_scope(ctestdir):
|
59 | 5 | """ test_1 is marked dependent on test_a in the test_a.py file, that test
|
60 | 6 | failed and causes test_1 to be skipped. Also test using session scope to
|
@@ -156,93 +102,3 @@ def test_3():
|
156 | 102 | *::test_2 SKIPPED
|
157 | 103 | *::test_3 PASSED
|
158 | 104 | """)
|
159 |
| - |
160 |
| - |
161 |
| - |
162 |
| - |
163 |
| -def test_complex_scope(ctestdir): |
164 |
| - """ A complex test of scope utilizing module, class and session scopes. Also utilizing the |
165 |
| - depends="all" modifier """ |
166 |
| - test_file1 = """ |
167 |
| - import pytest |
168 |
| -
|
169 |
| - @pytest.mark.dependency() |
170 |
| - def test_a(): |
171 |
| - assert False |
172 |
| -
|
173 |
| - @pytest.mark.dependency() |
174 |
| - def test_b(): |
175 |
| - pass |
176 |
| -
|
177 |
| - @pytest.mark.dependency(depends="all") |
178 |
| - def test_c(): |
179 |
| - pass |
180 |
| -
|
181 |
| - @pytest.mark.dependency(depends=["test_c"]) |
182 |
| - def test_d(): |
183 |
| - pass |
184 |
| -
|
185 |
| - class TestFile1(): |
186 |
| - @pytest.mark.dependency() |
187 |
| - def test_0(self): |
188 |
| - pass |
189 |
| - """ |
190 |
| - |
191 |
| - test_file2 = """ |
192 |
| - import pytest |
193 |
| -
|
194 |
| - def test_v(): |
195 |
| - pass |
196 |
| -
|
197 |
| - @pytest.mark.dependency(scope="session", depends="all") |
198 |
| - def test_w(): |
199 |
| - pass |
200 |
| -
|
201 |
| - @pytest.mark.dependency(scope="session", depends=["test_a.py::TestFile1::test_0"]) |
202 |
| - def test_x(): |
203 |
| - pass |
204 |
| -
|
205 |
| - class TestFile2(): |
206 |
| - def test_0(self): |
207 |
| - pass |
208 |
| -
|
209 |
| - @pytest.mark.dependency(scope="class", depends="all") |
210 |
| - def test_1(self): |
211 |
| - pass |
212 |
| -
|
213 |
| - @pytest.mark.dependency(scope="module", depends="all") |
214 |
| - def test_2(self): |
215 |
| - pass |
216 |
| -
|
217 |
| - @pytest.mark.dependency(scope="session", depends="all") |
218 |
| - def test_3(self): |
219 |
| - pass |
220 |
| -
|
221 |
| - @pytest.mark.dependency(scope="session", depends=["test_a.py::test_b"]) |
222 |
| - def test_y(): |
223 |
| - pass |
224 |
| -
|
225 |
| - @pytest.mark.dependency(scope="session", depends=["test_a.py::test_a"]) |
226 |
| - def test_z(): |
227 |
| - pass |
228 |
| - """ |
229 |
| - ctestdir.makepyfile(test_a=test_file1, test_b=test_file2) |
230 |
| - |
231 |
| - result = ctestdir.runpytest("--verbose", "test_a.py", "test_b.py") |
232 |
| - result.assert_outcomes(passed=7, skipped=6, failed=1) |
233 |
| - result.stdout.fnmatch_lines(""" |
234 |
| - *::test_a FAILED |
235 |
| - *::test_b PASSED |
236 |
| - *::test_c SKIPPED |
237 |
| - *::test_d SKIPPED |
238 |
| - *::TestFile1::test_0 PASSED |
239 |
| - *::test_v PASSED |
240 |
| - *::test_w SKIPPED |
241 |
| - *::test_x PASSED |
242 |
| - *::TestFile2::test_0 PASSED |
243 |
| - *::TestFile2::test_1 PASSED |
244 |
| - *::TestFile2::test_2 SKIPPED |
245 |
| - *::TestFile2::test_3 SKIPPED |
246 |
| - *::test_y PASSED |
247 |
| - *::test_z SKIPPED |
248 |
| - """) |
0 commit comments