diff --git a/pyproject.toml b/pyproject.toml index 3522e0c..a6197a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,3 +93,10 @@ include_trailing_comma = true multi_line_output = 3 known_first_party = ["nublado2", "tests"] skip = ["docs/conf.py"] + +[tool.pytest.ini_options] +asyncio_mode = "strict" +python_files = [ + "tests/*.py", + "tests/*/*.py" +] diff --git a/tests/auth_test.py b/tests/auth_test.py index f7d3f2c..d30a61c 100644 --- a/tests/auth_test.py +++ b/tests/auth_test.py @@ -7,10 +7,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import Any, AsyncGenerator, Callable, Dict from unittest.mock import MagicMock, patch import pytest +import pytest_asyncio from aioresponses import CallbackResult, aioresponses from tornado import web from tornado.httputil import HTTPHeaders @@ -21,11 +22,8 @@ _build_auth_info, ) -if TYPE_CHECKING: - from typing import Any, AsyncGenerator, Callable, Dict - -@pytest.fixture(autouse=True) +@pytest_asyncio.fixture(autouse=True) async def config_mock() -> AsyncGenerator: """Use a mock NubladoConfig object.""" with patch("nublado2.auth.NubladoConfig") as mock: diff --git a/tests/provisioner_test.py b/tests/provisioner_test.py index f8fda90..d1997c5 100644 --- a/tests/provisioner_test.py +++ b/tests/provisioner_test.py @@ -7,6 +7,7 @@ from unittest.mock import MagicMock, Mock, patch import pytest +import pytest_asyncio from aioresponses import CallbackResult, aioresponses from jupyterhub.spawner import Spawner from jupyterhub.user import User @@ -14,7 +15,7 @@ from nublado2.resourcemgr import ResourceManager -@pytest.fixture(autouse=True) +@pytest_asyncio.fixture(autouse=True) async def config_mock() -> AsyncGenerator: """Use a mock NubladoConfig object.""" with patch("nublado2.resourcemgr.NubladoConfig") as mock: diff --git a/tests/resourcemgr_test.py b/tests/resourcemgr_test.py index 9159393..6f96365 100644 --- a/tests/resourcemgr_test.py +++ b/tests/resourcemgr_test.py @@ -4,7 +4,7 @@ import asyncio import sys -from typing import TYPE_CHECKING +from typing import Any, Callable, Dict, Iterator, List from unittest.mock import Mock, patch import pytest @@ -25,9 +25,6 @@ from nublado2.resourcemgr import ResourceManager from nublado2.selectedoptions import SelectedOptions -if TYPE_CHECKING: - from typing import Any, Callable, Dict, Iterator, List - # Mock user resources template to test the template engine. USER_RESOURCES_TEMPLATE = """ - apiVersion: v1