Skip to content

Commit

Permalink
tests: type django_db_blocker fixtures
Browse files Browse the repository at this point in the history
This also serves as a typing test.
  • Loading branch information
bluetech committed Nov 8, 2023
1 parent d599fdb commit 017bd77
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .helpers import DjangoPytester

from pytest_django import DjangoDbBlocker
from pytest_django_test.app.models import Item


Expand Down Expand Up @@ -690,7 +691,7 @@ class Migration(migrations.Migration):

class Test_django_db_blocker:
@pytest.mark.django_db
def test_block_manually(self, django_db_blocker) -> None:
def test_block_manually(self, django_db_blocker: DjangoDbBlocker) -> None:
try:
django_db_blocker.block()
with pytest.raises(RuntimeError):
Expand All @@ -699,19 +700,19 @@ def test_block_manually(self, django_db_blocker) -> None:
django_db_blocker.restore()

@pytest.mark.django_db
def test_block_with_block(self, django_db_blocker) -> None:
def test_block_with_block(self, django_db_blocker: DjangoDbBlocker) -> None:
with django_db_blocker.block():
with pytest.raises(RuntimeError):
Item.objects.exists()

def test_unblock_manually(self, django_db_blocker) -> None:
def test_unblock_manually(self, django_db_blocker: DjangoDbBlocker) -> None:
try:
django_db_blocker.unblock()
Item.objects.exists()
finally:
django_db_blocker.restore()

def test_unblock_with_block(self, django_db_blocker) -> None:
def test_unblock_with_block(self, django_db_blocker: DjangoDbBlocker) -> None:
with django_db_blocker.unblock():
Item.objects.exists()

Expand Down

0 comments on commit 017bd77

Please sign in to comment.