Skip to content

Commit cef281f

Browse files
committed
fix: fork set handling
1 parent 1b1bbc4 commit cef281f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pytest_plugins/forks/forks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ def fork(request):
562562

563563
ALL_VALIDITY_MARKERS: List["Type[ValidityMarker]"] = []
564564

565+
MARKER_NAME_REGEX = re.compile(r"(?<!^)(?=[A-Z])")
566+
565567

566568
@dataclass(kw_only=True)
567569
class ValidityMarker:
@@ -595,15 +597,14 @@ def __init_subclass__(
595597
cls.marker_name = marker_name
596598
else:
597599
# Use the class name converted to underscore: https://stackoverflow.com/a/1176023
598-
cls.marker_name = re.sub(r"(?<!^)(?=[A-Z])", "_", cls.__name__).lower()
600+
cls.marker_name = MARKER_NAME_REGEX.sub("_", cls.__name__).lower()
599601
cls.mutually_exclusive = mutually_exclusive
600602
if cls in ALL_VALIDITY_MARKERS:
601603
raise ValueError(f"Duplicate validity marker class: {cls}")
602604
ALL_VALIDITY_MARKERS.append(cls)
603605

604606
def process_fork_arguments(self, *fork_args: str) -> Set[Fork]:
605607
"""Process the fork arguments."""
606-
forks: Set[Fork] = set()
607608
fork_names: Set[str] = set()
608609
for fork_arg in fork_args:
609610
fork_names_list = fork_arg.strip().split(",")
@@ -614,6 +615,7 @@ def process_fork_arguments(self, *fork_args: str) -> Set[Fork]:
614615
f"'{self.test_name}': Duplicate argument specified in "
615616
f"'{self.marker_name}'."
616617
)
618+
forks: Set[Fork] = set()
617619
for fork_name in fork_names:
618620
if fork_name not in self.all_forks_by_name:
619621
pytest.fail(f"'{self.test_name}': Invalid fork '{fork_name}' specified.")
@@ -759,7 +761,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
759761
test_fork_set: Set[Fork] = metafunc.config.all_forks_with_transitions # type: ignore
760762
for validity_marker in validity_markers:
761763
# Apply the validity markers to the test function if applicable
762-
test_fork_set &= validity_marker.process()
764+
test_fork_set = test_fork_set & validity_marker.process()
763765

764766
if not test_fork_set:
765767
pytest.fail(

0 commit comments

Comments
 (0)