From 63074a3239368ec1e52aaac7ff00eaf9ec56e263 Mon Sep 17 00:00:00 2001 From: Vishal Goyal Date: Mon, 5 Jan 2026 21:13:47 +0530 Subject: [PATCH 1/5] fix: set asyncio_default_fixture_loop_scope to avoid pytest warning --- api_app/pytest.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api_app/pytest.ini b/api_app/pytest.ini index 9e90ef7cb8..56f124a8e4 100644 --- a/api_app/pytest.ini +++ b/api_app/pytest.ini @@ -1,3 +1,5 @@ [pytest] filterwarnings = error +asyncio_mode = auto +asyncio_default_fixture_loop_scope = function From 093484585d5604ea4890e8979a8a17ae7654ac2a Mon Sep 17 00:00:00 2001 From: James Chapman Date: Wed, 7 Jan 2026 11:17:09 +0000 Subject: [PATCH 2/5] fix fixture definitions and use strict mode --- api_app/pytest.ini | 2 +- api_app/tests_ma/test_api/conftest.py | 2 +- api_app/tests_ma/test_api/test_routes/test_airlock.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api_app/pytest.ini b/api_app/pytest.ini index 56f124a8e4..a86e89e4bb 100644 --- a/api_app/pytest.ini +++ b/api_app/pytest.ini @@ -1,5 +1,5 @@ [pytest] filterwarnings = error -asyncio_mode = auto +asyncio_mode = strict asyncio_default_fixture_loop_scope = function diff --git a/api_app/tests_ma/test_api/conftest.py b/api_app/tests_ma/test_api/conftest.py index b386ce32bd..91c278a14d 100644 --- a/api_app/tests_ma/test_api/conftest.py +++ b/api_app/tests_ma/test_api/conftest.py @@ -126,7 +126,7 @@ def inner(): return inner -@pytest_asyncio.fixture(scope='module') +@pytest.fixture(scope='module') def app() -> FastAPI: from main import get_application diff --git a/api_app/tests_ma/test_api/test_routes/test_airlock.py b/api_app/tests_ma/test_api/test_routes/test_airlock.py index 852ef09dbe..d7e9f80749 100644 --- a/api_app/tests_ma/test_api/test_routes/test_airlock.py +++ b/api_app/tests_ma/test_api/test_routes/test_airlock.py @@ -127,7 +127,7 @@ def inner(): class TestAirlockRoutesThatRequireOwnerOrResearcherRights(): - @pytest_asyncio.fixture(autouse=True, scope='class') + @pytest.fixture(autouse=True, scope='class') def log_in_with_researcher_user(self, app, researcher_user): app.dependency_overrides[get_current_workspace_owner_or_researcher_user] = researcher_user app.dependency_overrides[get_current_workspace_owner_or_researcher_user_or_airlock_manager] = researcher_user @@ -303,7 +303,7 @@ async def test_get_airlock_container_link_returned_as_expected(self, get_airlock class TestAirlockRoutesThatRequireAirlockManagerRights(): - @pytest_asyncio.fixture(autouse=True, scope='class') + @pytest.fixture(autouse=True, scope='class') def log_in_with_airlock_manager_user(self, app, airlock_manager_user): app.dependency_overrides[get_current_airlock_manager_user] = airlock_manager_user app.dependency_overrides[get_current_workspace_owner_or_researcher_user_or_airlock_manager] = airlock_manager_user From ad4d1842bb8e16696776f6ac74588bc6dce7a82f Mon Sep 17 00:00:00 2001 From: James Chapman Date: Wed, 7 Jan 2026 11:51:26 +0000 Subject: [PATCH 3/5] add pyproject.toml to project root --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..c5b6490619 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[tool.bandit] +exclude_dirs = ["api_app/tests_ma", "airlock_processor/tests", "airlock_processor/.venv", "resource_processor/tests_rp", "e2e_tests", "docs"] + +[tool.pytest.ini_options] +asyncio_mode = "strict" +asyncio_default_fixture_loop_scope = "function" From 083066a3c93a15d62678f521ee8027a681fc21fe Mon Sep 17 00:00:00 2001 From: James Chapman Date: Thu, 8 Jan 2026 10:04:10 +0000 Subject: [PATCH 4/5] remove async where not needed --- api_app/tests_ma/test_api/test_routes/test_airlock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api_app/tests_ma/test_api/test_routes/test_airlock.py b/api_app/tests_ma/test_api/test_routes/test_airlock.py index d7e9f80749..f919d41525 100644 --- a/api_app/tests_ma/test_api/test_routes/test_airlock.py +++ b/api_app/tests_ma/test_api/test_routes/test_airlock.py @@ -1,6 +1,5 @@ import time import pytest -import pytest_asyncio from mock import patch from fastapi import status from azure.core.exceptions import HttpResponseError @@ -463,7 +462,7 @@ async def test_post_revoke_airlock_request_missing_reason_returns_422(self, _, a class TestAirlockRoutesPermissions(): - @pytest_asyncio.fixture() + @pytest.fixture() def log_in_with_user(self, app): def inner(user): app.dependency_overrides[get_current_workspace_owner_or_researcher_user] = user From 473bb15d7939527d8cc135364e5b011dbd98f89b Mon Sep 17 00:00:00 2001 From: James Chapman Date: Mon, 24 Aug 2026 14:35:57 +0000 Subject: [PATCH 5/5] Configure pytest-asyncio fixture loop scope --- CHANGELOG.md | 3 +++ api_app/_version.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a57a4c1ca..a9c73e3480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ENHANCEMENTS: +BUG FIXES: +* Configure the default pytest-asyncio fixture loop scope to `function` to remove the deprecation warning. ([#5055](https://github.com/microsoft/AzureTRE/pull/5055)) + ## (0.29.0) (August 14, 2026) **BREAKING CHANGES** * Remove Windows 10 and dsvm image support from Guacamole. ([#4890](https://github.com/microsoft/AzureTRE/issues/4890)) diff --git a/api_app/_version.py b/api_app/_version.py index ae62eb6326..1932d0ba38 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.26.5" +__version__ = "0.26.6"