[Test Proxy] recorded_test compatible with any pytest-asyncio
@@ -26,6 +26,13 @@ if TYPE_CHECKING:
from typing import Any, Callable, Dict, Optional, Tuple
from pytest import FixtureRequest
+# In pytest-asyncio>=0.19.0 async fixtures need to be marked with pytest_asyncio.fixture, not pytest.fixture, by default
+# pytest_asyncio.fixture is only recently available (~0.17.0), so we need to account for an import error
+try:
+ from pytest_asyncio import fixture as async_fixture
+except ImportError:
+ from pytest import fixture as async_fixture
+
_LOGGER = logging.getLogger()
@@ -115,7 +122,7 @@ def environment_variables(test_proxy: None) -> EnvironmentVariableSanitizer:
return EnvironmentVariableSanitizer()
-@pytest.fixture
+@async_fixture
async def recorded_test(test_proxy: None, request: "FixtureRequest") -> "Dict[str, Any]":
"""Fixture that redirects network requests to target the azure-sdk-tools test proxy.
