Skip to content

Commit ede6840

Browse files
author
Lode Rosseel
committed
Implement code comments
1 parent bf45db8 commit ede6840

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pytest_django/fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import os
6-
from collections.abc import AsyncGenerator, Generator, Iterable, Sequence
6+
from collections.abc import Generator, Iterable, Sequence
77
from contextlib import AbstractContextManager, contextmanager
88
from functools import partial
99
from typing import TYPE_CHECKING, Protocol
@@ -16,6 +16,7 @@
1616

1717

1818
if TYPE_CHECKING:
19+
from collections.abc import AsyncGenerator
1920
from typing import Any, Callable, Literal, Optional, Union
2021

2122
import django

tests/test_async_db.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@pytest.mark.parametrize("run_number", [1, 2])
2323
@pytestmark
2424
@pytest.mark.django_db
25-
async def test_async_db(db, run_number) -> None:
25+
async def test_async_db(run_number: int) -> None: # noqa: ARG001
2626
# test async database usage remains isolated between tests
2727

2828
assert await Item.objects.acount() == 0
@@ -32,18 +32,19 @@ async def test_async_db(db, run_number) -> None:
3232

3333

3434
@fixturemark
35-
async def db_item(db) -> Any:
35+
async def db_item() -> Any:
3636
return await Item.objects.acreate(name="async")
3737

3838

3939
@pytest.fixture
40-
def sync_db_item(db) -> Any:
40+
def sync_db_item() -> Any:
4141
return Item.objects.create(name="sync")
4242

4343

4444
@pytestmark
4545
@pytest.mark.xfail(strict=True, reason="Sync fixture used in async test")
46-
async def test_db_item(db_item: Item, sync_db_item) -> None:
46+
@pytest.mark.usefixtures("db_item", "sync_db_item")
47+
async def test_db_item() -> None:
4748
pass
4849

4950

0 commit comments

Comments
 (0)