@@ -18,11 +18,13 @@ def test_get_module():
18
18
assert 'test.py' == get_module ('test.py::test_foo' )
19
19
assert 'test.py' == get_module ('test.py::test_foo[1]' )
20
20
21
+
21
22
def test_get_function ():
22
23
assert None == get_function ('test.py' )
23
24
assert 'test_foo' == get_function ('test.py::test_foo' )
24
25
assert 'test_foo' == get_function ('test.py::test_foo[1]' )
25
26
27
+
26
28
def test_run_pytest_collect_failure (tests_dir ):
27
29
test1 = seq2p (tests_dir , 1 )
28
30
test1 .write_text (dedent ("""\
@@ -148,15 +150,37 @@ def test_reduce_test_fails_by_itself(tests_dir, r):
148
150
@pytest .mark .parametrize ("pollute_in_collect, fail_collect" , [[False , False ], [True , False ], [True , True ]])
149
151
@pytest .mark .parametrize ("r" , [reduce .reduce , cli_reduce ])
150
152
def test_reduce (tests_dir , pollute_in_collect , fail_collect , r ):
151
- failing , polluter , tests = make_polluted_suite (tests_dir , fail_collect = fail_collect , pollute_in_collect = pollute_in_collect )
153
+ failing , polluter , tests = make_polluted_suite (tests_dir , fail_collect = fail_collect ,
154
+ pollute_in_collect = pollute_in_collect )
152
155
153
156
reduction_file = tests_dir .parent / "reduction.json"
154
157
155
158
reduction = r (tests_path = tests_dir , trace = True )
156
159
157
160
assert reduction ['failed' ] == failing
158
161
assert reduction ['modules' ] == [get_module (polluter )]
159
- assert reduction ['tests' ] == [] if pollute_in_collect else [polluter ]
162
+ # this would be more precise... is it the test or the module?
163
+ # assert reduction['modules'] == ([get_module(polluter)] if pollute_in_collect else [])
164
+ assert reduction ['tests' ] == ([] if pollute_in_collect else [polluter ])
165
+
166
+
167
+ @pytest .mark .parametrize ("pollute_in_collect, fail_collect" , [[False , False ], [True , False ], [True , True ]])
168
+ @pytest .mark .parametrize ("r" , [reduce .reduce , cli_reduce ])
169
+ def test_reduce_pytest_args (tests_dir , pollute_in_collect , fail_collect , r ):
170
+ failing , polluter , tests = make_polluted_suite (tests_dir , fail_collect = fail_collect ,
171
+ pollute_in_collect = pollute_in_collect )
172
+
173
+ (tests_dir / "conftest.py" ).write_text (dedent ("""\
174
+ if read, this breaks everything
175
+ """ ))
176
+
177
+ reduction = r (tests_path = tests_dir , trace = True , pytest_args = ['--noconftest' ])
178
+
179
+ assert reduction ['failed' ] == failing
180
+ assert reduction ['modules' ] == [get_module (polluter )]
181
+ # this would be more precise... is it the test or the module?
182
+ # assert reduction['modules'] == ([get_module(polluter)] if pollute_in_collect else [])
183
+ assert reduction ['tests' ] == ([] if pollute_in_collect else [polluter ])
160
184
161
185
162
186
@pytest .mark .parametrize ("r" , [reduce .reduce , cli_reduce ])
@@ -191,22 +215,6 @@ def test_nothing():
191
215
assert reduction ['tests' ] == []
192
216
193
217
194
- @pytest .mark .parametrize ("pollute_in_collect, fail_collect" , [[False , False ], [True , False ], [True , True ]])
195
- @pytest .mark .parametrize ("r" , [reduce .reduce , cli_reduce ])
196
- def test_reduce_pytest_args (tests_dir , pollute_in_collect , fail_collect , r ):
197
- failing , polluter , tests = make_polluted_suite (tests_dir , fail_collect = fail_collect , pollute_in_collect = pollute_in_collect )
198
-
199
- (tests_dir / "conftest.py" ).write_text (dedent ("""\
200
- if read, this breaks everything
201
- """ ))
202
-
203
- reduction = r (tests_path = tests_dir , trace = True , pytest_args = ['--noconftest' ])
204
-
205
- assert reduction ['failed' ] == failing
206
- assert reduction ['modules' ] == [get_module (polluter )]
207
- assert reduction ['tests' ] == [] if pollute_in_collect else [polluter ]
208
-
209
-
210
218
@pytest .mark .parametrize ("r" , [reduce .reduce , cli_reduce ])
211
219
def test_reduce_polluter_test_in_single_module (tests_dir , r ):
212
220
test = seq2p (tests_dir , 0 )
0 commit comments