|
5 | 5 |
|
6 | 6 | import re |
7 | 7 | from types import ModuleType |
| 8 | +from typing import List, Set |
8 | 9 |
|
9 | 10 | import pytest |
10 | 11 | from _pytest.nodes import Item |
@@ -132,20 +133,19 @@ def reportinfo(self): |
132 | 133 | return "spec_version_checker", 0, f"{self.name}" |
133 | 134 |
|
134 | 135 |
|
135 | | -def pytest_collection_modifyitems(session, config, items): |
| 136 | +def pytest_collection_modifyitems( |
| 137 | + session: pytest.Session, config: pytest.Config, items: List[Item] |
| 138 | +): |
136 | 139 | """ |
137 | 140 | Insert a new test EIPSpecTestItem for every test modules that |
138 | 141 | contains 'eip' in its path. |
139 | 142 | """ |
140 | | - modules = {item.parent for item in items if isinstance(item.parent, Module)} |
| 143 | + modules: Set[Module] = {item.parent for item in items if isinstance(item.parent, Module)} |
141 | 144 | new_test_eip_spec_version_items = [ |
142 | 145 | EIPSpecTestItem.from_parent(module, module.obj) |
143 | | - for module in modules |
| 146 | + for module in sorted(modules, key=lambda module: module.path) |
144 | 147 | if is_test_for_an_eip(str(module.path)) |
145 | 148 | ] |
146 | 149 | for item in new_test_eip_spec_version_items: |
147 | 150 | item.add_marker("eip_version_check", append=True) |
148 | 151 | items.extend(new_test_eip_spec_version_items) |
149 | | - # this gives a nice ordering for the new tests added here, but re-orders the entire |
150 | | - # default pytest item ordering which based on ordering of test functions in test modules |
151 | | - # items.sort(key=lambda x: x.nodeid) |
0 commit comments