9
9
10
10
import pytest_cleanslate .reduce as reduce
11
11
12
- from pytest_cleanslate .reduce import MODULE_LIST_ARG , TEST_LIST_ARG , RESULTS_ARG , Results
12
+ from pytest_cleanslate .reduce import MODULE_LIST_ARG , TEST_LIST_ARG , RESULTS_ARG , Results , \
13
+ get_module , get_function
13
14
14
15
15
- def get_test_module (testid ):
16
- return testid .split ('::' )[0 ]
16
+ def test_get_module ():
17
+ assert 'test.py' == get_module ('test.py' )
18
+ assert 'test.py' == get_module ('test.py::test_foo' )
19
+ assert 'test.py' == get_module ('test.py::test_foo[1]' )
17
20
21
+ def test_get_function ():
22
+ assert None == get_function ('test.py' )
23
+ assert 'test_foo' == get_function ('test.py::test_foo' )
24
+ assert 'test_foo' == get_function ('test.py::test_foo[1]' )
18
25
19
26
def test_run_pytest_collect_failure (tests_dir ):
20
27
test1 = seq2p (tests_dir , 1 )
@@ -148,7 +155,7 @@ def test_reduce(tests_dir, pollute_in_collect, fail_collect, r):
148
155
reduction = r (tests_path = tests_dir , trace = True )
149
156
150
157
assert reduction ['failed' ] == failing
151
- assert reduction ['modules' ] == [get_test_module (polluter )]
158
+ assert reduction ['modules' ] == [get_module (polluter )]
152
159
assert reduction ['tests' ] == [] if pollute_in_collect else [polluter ]
153
160
154
161
@@ -180,7 +187,7 @@ def test_nothing():
180
187
reduction = r (tests_path = tests_dir , trace = True )
181
188
182
189
assert reduction ['failed' ] == failing
183
- assert reduction ['modules' ] == [get_test_module (polluter )]
190
+ assert reduction ['modules' ] == [get_module (polluter )]
184
191
assert reduction ['tests' ] == []
185
192
186
193
@@ -196,7 +203,7 @@ def test_reduce_pytest_args(tests_dir, pollute_in_collect, fail_collect, r):
196
203
reduction = r (tests_path = tests_dir , trace = True , pytest_args = ['--noconftest' ])
197
204
198
205
assert reduction ['failed' ] == failing
199
- assert reduction ['modules' ] == [get_test_module (polluter )]
206
+ assert reduction ['modules' ] == [get_module (polluter )]
200
207
assert reduction ['tests' ] == [] if pollute_in_collect else [polluter ]
201
208
202
209
0 commit comments