Skip to content

Commit f3933ed

Browse files
committed
fix: Improve async test detection for Python 3.7
- Use a list of async keywords (async, asgi, aio, starlette) - Check for these keywords in test names, file paths, and parameters - This catches more async-related tests including those with "aio" prefix
1 parent 7009b19 commit f3933ed

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

conftest.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,17 @@ def pytest_collection_modifyitems(config, items):
6767
reason="Async features require Python 3.8+ (Starlette dependency)"
6868
)
6969

70+
# Keywords that indicate async-related tests
71+
async_keywords = ["async", "asgi", "aio", "starlette"]
72+
7073
for item in items:
7174
skip_test = False
7275

7376
if hasattr(item, "callspec") and hasattr(item.callspec, "params"):
7477
for param_name, param_value in item.callspec.params.items():
75-
# Check if test has fixtures with async parameters
76-
if isinstance(param_value, str) and (
77-
"async" in param_value or param_value.startswith("async_")
78+
# Check if test has fixtures with async-related parameters
79+
if isinstance(param_value, str) and any(
80+
keyword in param_value.lower() for keyword in async_keywords
7881
):
7982
skip_test = True
8083
break
@@ -87,12 +90,12 @@ def pytest_collection_modifyitems(config, items):
8790
test_file = str(item.fspath)
8891
test_name = item.name
8992

90-
# Skip tests in async-specific test files (backup for any not caught by ignore)
91-
if "test_aio" in test_file:
93+
# Skip tests in files with async-related keywords
94+
if any(keyword in test_file.lower() for keyword in async_keywords):
9295
skip_test = True
9396

9497
# Skip tests that explicitly test async functionality
95-
if "async" in test_name.lower() or "asgi" in test_name.lower():
98+
if any(keyword in test_name.lower() for keyword in async_keywords):
9699
skip_test = True
97100

98101
if skip_test:

0 commit comments

Comments
 (0)