Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions examples/blacksheep/_tests.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# mypy: no-disallow-untyped-decorators
# pylint: disable=E0611,E0401
import pytest
import pytest_asyncio
from blacksheep import JSONContent
from blacksheep.testing import TestClient
from models import Users
from server import app


@pytest_asyncio.fixture(scope="session", loop_scope="session")
@pytest.fixture(scope="session")
def anyio_backend() -> str:
return "asyncio"


@pytest.fixture(scope="session")
async def client(api):
return TestClient(api)


@pytest_asyncio.fixture(scope="session", loop_scope="session")
@pytest.fixture(scope="session")
async def api():
await app.start()
yield app
await app.stop()


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_get_uses_list(client: TestClient) -> None:
username = "john"
await Users.create(username=username)
Expand All @@ -39,7 +43,7 @@ async def test_get_uses_list(client: TestClient) -> None:
assert str(user_obj.id) == user_id # nosec


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_create_user(client: TestClient) -> None:
username = "john"

Expand All @@ -54,7 +58,7 @@ async def test_create_user(client: TestClient) -> None:
assert str(user_obj.id) == user_id # nosec


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_update_user(client: TestClient) -> None: # nosec
user = await Users.create(username="john")

Expand All @@ -70,7 +74,7 @@ async def test_update_user(client: TestClient) -> None: # nosec
assert str(user_obj.id) == user_id # nosec


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_delete_user(client: TestClient) -> None:
user = await Users.create(username="john")

Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ dev = [
# Linter tools
"mypy",
"ruff",
"darglint",
"pylint",
"bandit",
"codespell",
Expand Down Expand Up @@ -92,7 +91,7 @@ contrib=[
"aiohttp",
# BlackSheep support
"blacksheep>=2.0.8",
"pytest-asyncio>=0.24.0",
"PyJWT >=2.10.1; python_version < '3.10'",
]
test = [
# Test tools
Expand Down Expand Up @@ -123,7 +122,6 @@ include = ["CHANGELOG.rst", "LICENSE", "README.rst"]
[tool.mypy]
pretty = true
exclude = ["docs"]
python_version = "3.9"
ignore_missing_imports = true
check_untyped_defs = true
disallow_subclassing_any = true
Expand Down Expand Up @@ -188,7 +186,6 @@ per-file-ignores = [
docstring_style = "sphinx"

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "session"
filterwarnings = [
'ignore:`pk` is deprecated:DeprecationWarning',
'ignore:`index` is deprecated:DeprecationWarning',
Expand Down
Loading
Loading