From 081ad89b844a8080539e2b45cb315156778bf3c1 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 21 Oct 2024 12:05:56 -0500 Subject: [PATCH] PYTHON-4894 Fix handling of auth test marker (#1958) --- test/pytest_conf.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/test/pytest_conf.py b/test/pytest_conf.py index 75f3e7432..a6e24cd9b 100644 --- a/test/pytest_conf.py +++ b/test/pytest_conf.py @@ -2,15 +2,14 @@ from __future__ import annotations def pytest_collection_modifyitems(items, config): - sync_items = [] - async_items = [ - item - for item in items - if "asynchronous" in item.fspath.dirname or sync_items.append(item) # type: ignore[func-returns-value] - ] - for item in async_items: - if not any(item.iter_markers()): - item.add_marker("default_async") - for item in sync_items: - if not any(item.iter_markers()): - item.add_marker("default") + # Markers that should overlap with the default markers. + overlap_markers = ["async"] + + for item in items: + if "asynchronous" in item.fspath.dirname: + default_marker = "default_async" + else: + default_marker = "default" + markers = [m for m in item.iter_markers() if m not in overlap_markers] + if not markers: + item.add_marker(default_marker)