report bad @pytest.mark.limit_consensus_modes() use with fixtureless tests (#16224)

report bad `@pytest.mark.limit_consensus_modes()` use fixtureless tests
This commit is contained in:
Kyle Altendorf 2023-09-07 15:33:23 -04:00 committed by GitHub
parent 1c5b469c5b
commit 5cf8d2f27f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -330,9 +330,15 @@ def pytest_collection_modifyitems(session, config: pytest.Config, items: List[py
for item in items:
limit_consensus_modes_marker = item.get_closest_marker("limit_consensus_modes")
if limit_consensus_modes_marker is not None:
mode = item.callspec.params.get("consensus_mode")
callspec = getattr(item, "callspec", None)
if callspec is None:
limit_consensus_modes_problems.append(item.name)
continue
mode = callspec.params.get("consensus_mode")
if mode is None:
limit_consensus_modes_problems.append(item.name)
continue
modes = limit_consensus_modes_marker.kwargs.get("allowed", [ConsensusMode.PLAIN])
if mode not in modes: