Skip to content

Commit

Permalink
Fix warnings from new pytest-asyncio
Browse files Browse the repository at this point in the history
The new pytest-asyncio requires some new configuration and new
ways of marking fixtures.
  • Loading branch information
rra committed Jan 24, 2022
1 parent dde7c83 commit 359f98a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
8 changes: 3 additions & 5 deletions tests/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/provisioner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
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

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:
Expand Down
5 changes: 1 addition & 4 deletions tests/resourcemgr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 359f98a

Please sign in to comment.