Skip to content

Commit 01f496f

Browse files
authored
fix(plugins/spec_version_checker): Sort modules (#1357)
* fix(plugins/spec_version_checker): Sort modules * nit
1 parent b7c956b commit 01f496f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pytest_plugins/spec_version_checker/spec_version_checker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import re
77
from types import ModuleType
8+
from typing import List, Set
89

910
import pytest
1011
from _pytest.nodes import Item
@@ -132,20 +133,19 @@ def reportinfo(self):
132133
return "spec_version_checker", 0, f"{self.name}"
133134

134135

135-
def pytest_collection_modifyitems(session, config, items):
136+
def pytest_collection_modifyitems(
137+
session: pytest.Session, config: pytest.Config, items: List[Item]
138+
):
136139
"""
137140
Insert a new test EIPSpecTestItem for every test modules that
138141
contains 'eip' in its path.
139142
"""
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)}
141144
new_test_eip_spec_version_items = [
142145
EIPSpecTestItem.from_parent(module, module.obj)
143-
for module in modules
146+
for module in sorted(modules, key=lambda module: module.path)
144147
if is_test_for_an_eip(str(module.path))
145148
]
146149
for item in new_test_eip_spec_version_items:
147150
item.add_marker("eip_version_check", append=True)
148151
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

Comments
 (0)