Skip to content

Commit 9debb02

Browse files
committed
conftest(fix[doctest]): Add rerun markers for tmux-dependent doctests
why: Tmux doctests are inherently timing-sensitive — shell startup races can cause spurious failures even with generous timeouts. what: - Add pytest_collection_modifyitems hook to apply flaky(reruns=2) marker to DoctestItems from DOCTEST_NEEDS_TMUX modules
1 parent 818466e commit 9debb02

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ def socket_name(request: pytest.FixtureRequest) -> str:
104104
}
105105

106106

107+
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
108+
"""Add rerun markers to tmux-dependent doctests for flaky shell timing."""
109+
for item in items:
110+
if isinstance(item, DoctestItem):
111+
module_name = item.dtest.globs.get("__name__", "")
112+
if module_name in DOCTEST_NEEDS_TMUX:
113+
item.add_marker(pytest.mark.flaky(reruns=2))
114+
115+
107116
@pytest.fixture(autouse=True)
108117
def add_doctest_fixtures(
109118
request: pytest.FixtureRequest,

0 commit comments

Comments
 (0)