| 39 | # automatically add `pytest.mark.asyncio()` to all of our async tests |
| 40 | # so we don't have to add that boilerplate everywhere |
| 41 | def pytest_collection_modifyitems(items: list[pytest.Function]) -> None: |
| 42 | pytest_asyncio_tests = (item for item in items if is_async_test(item)) |
| 43 | session_scope_marker = pytest.mark.asyncio(loop_scope="session") |
| 44 | for async_test in pytest_asyncio_tests: |
| 45 | async_test.add_marker(session_scope_marker, append=False) |
| 46 | |
| 47 | # We skip tests that use both the aiohttp client and respx_mock as respx_mock |
| 48 | # doesn't support custom transports. |
| 49 | for item in items: |
| 50 | if "async_client" not in item.fixturenames or "respx_mock" not in item.fixturenames: |
| 51 | continue |
| 52 | |
| 53 | if not hasattr(item, "callspec"): |
| 54 | continue |
| 55 | |
| 56 | async_client_param = item.callspec.params.get("async_client") |
| 57 | if is_dict(async_client_param) and async_client_param.get("http_client") == "aiohttp": |
| 58 | item.add_marker(pytest.mark.skip(reason="aiohttp client is not compatible with respx_mock")) |
| 59 | |
| 60 | |
| 61 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |