|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 |
|
8 | | -Call = collections.namedtuple('Call', field_names=('package', 'module', 'cls', 'name')) |
9 | | - |
10 | | - |
11 | | -def get_runtest_call_sequence(result): |
12 | | - """ |
13 | | - Returns a tuple of names of test methods that were run |
14 | | - in the order they were run. |
15 | | - """ |
16 | | - calls = [] |
17 | | - |
18 | | - for c in result.reprec.getcalls('pytest_runtest_call'): |
19 | | - calls.append(Call( |
20 | | - package=c.item.module.__package__, |
21 | | - module=c.item.module.__name__, |
22 | | - cls=(c.item.module.__name__, c.item.cls.__name__) if c.item.cls else None, |
23 | | - name=c.item.name, |
24 | | - )) |
25 | | - return tuple(calls) |
26 | | - |
27 | | - |
28 | 8 | @pytest.fixture |
29 | 9 | def tmp_tree_of_tests(testdir): |
30 | 10 | """ |
@@ -156,13 +136,13 @@ def inspect_attr(this_call, prev_call, attr_name): |
156 | 136 |
|
157 | 137 |
|
158 | 138 | @pytest.mark.parametrize('bucket', ['class', 'module', 'package', 'global']) |
159 | | -def test_it_works_with_actual_tests(tmp_tree_of_tests, bucket): |
| 139 | +def test_it_works_with_actual_tests(tmp_tree_of_tests, get_test_calls, bucket): |
160 | 140 | sequences = set() |
161 | 141 |
|
162 | 142 | for x in range(5): |
163 | 143 | result = tmp_tree_of_tests.runpytest('--random-order-bucket={}'.format(bucket), '--verbose') |
164 | 144 | result.assert_outcomes(passed=14, failed=3) |
165 | | - seq = get_runtest_call_sequence(result) |
| 145 | + seq = get_test_calls(result) |
166 | 146 | check_call_sequence(seq, bucket=bucket) |
167 | 147 | assert len(seq) == 17 |
168 | 148 | sequences.add(seq) |
|
0 commit comments