PYTHON-4613 Skip async tests when testing eventlet/gevent (#1780)
This commit is contained in:
parent
2afbd4b279
commit
a232b657d0
@ -60,8 +60,18 @@ def run(framework_name, *args):
|
||||
# Monkey-patch.
|
||||
FRAMEWORKS[framework_name]()
|
||||
|
||||
arg_list = list(args)
|
||||
|
||||
# Never run async tests with a framework
|
||||
if len(arg_list) <= 1:
|
||||
arg_list.extend(["-m", "not default_async and default"])
|
||||
else:
|
||||
for i in range(len(arg_list) - 1):
|
||||
if "-m" in arg_list[i]:
|
||||
arg_list[i + 1] = f"not default_async and {arg_list[i + 1]}"
|
||||
|
||||
# Run the tests.
|
||||
sys.exit(pytest.main(list(args)))
|
||||
sys.exit(pytest.main(arg_list))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@ -41,7 +41,7 @@ features = ["test"]
|
||||
[envs.test.scripts]
|
||||
test = "pytest -v --durations=5 --maxfail=10 {args}"
|
||||
test-eg = "bash ./.evergreen/run-tests.sh {args}"
|
||||
test-async = "test test/asynchronous/ {args}"
|
||||
test-async = "pytest -v --durations=5 --maxfail=10 -m default_async {args}"
|
||||
test-mockupdb = ["pip install -U git+https://github.com/ajdavis/mongo-mockup-db@master", "test -m mockupdb"]
|
||||
|
||||
[envs.encryption]
|
||||
|
||||
@ -70,7 +70,7 @@ zstd = ["requirements/zstd.txt"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "7"
|
||||
addopts = ["-ra", "--strict-config", "--strict-markers", "--junitxml=xunit-results/TEST-results.xml", "-m default"]
|
||||
addopts = ["-ra", "--strict-config", "--strict-markers", "--junitxml=xunit-results/TEST-results.xml", "-m default or default_async"]
|
||||
testpaths = ["test"]
|
||||
log_cli_level = "INFO"
|
||||
faulthandler_timeout = 1500
|
||||
@ -108,6 +108,7 @@ markers = [
|
||||
"load_balancer: load balancer tests",
|
||||
"mockupdb: tests that rely on mockupdb",
|
||||
"default: default test suite",
|
||||
"default_async: default async test suite",
|
||||
]
|
||||
|
||||
[tool.mypy]
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from test import pytest_conf
|
||||
from test.asynchronous import async_setup, async_teardown
|
||||
|
||||
import pytest_asyncio
|
||||
@ -14,7 +15,4 @@ async def test_setup_and_teardown():
|
||||
await async_teardown()
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(items, config):
|
||||
for item in items:
|
||||
if not any(item.iter_markers()):
|
||||
item.add_marker("default")
|
||||
pytest_collection_modifyitems = pytest_conf.pytest_collection_modifyitems
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from test import setup, teardown
|
||||
from test import pytest_conf, setup, teardown
|
||||
|
||||
import pytest
|
||||
|
||||
@ -14,7 +14,4 @@ def test_setup_and_teardown():
|
||||
teardown()
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(items, config):
|
||||
for item in items:
|
||||
if not any(item.iter_markers()):
|
||||
item.add_marker("default")
|
||||
pytest_collection_modifyitems = pytest_conf.pytest_collection_modifyitems
|
||||
|
||||
16
test/pytest_conf.py
Normal file
16
test/pytest_conf.py
Normal file
@ -0,0 +1,16 @@
|
||||
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")
|
||||
@ -95,6 +95,7 @@ replacements = {
|
||||
"aclose": "close",
|
||||
"async-transactions-ref": "transactions-ref",
|
||||
"async-snapshot-reads-ref": "snapshot-reads-ref",
|
||||
"default_async": "default",
|
||||
}
|
||||
|
||||
docstring_replacements: dict[tuple[str, str], str] = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user