Skip to content

Commit

Permalink
Some type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech committed Nov 7, 2023
1 parent 9fcdf5f commit 9047da6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions pytest_django/django_compat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Note that all functions here assume django is available. So ensure
# this is the case before you call them.
from __future__ import annotations

import pytest

def is_django_unittest(request_or_item) -> bool:
"""Returns True if the request_or_item is a Django test case, otherwise False"""

def is_django_unittest(request_or_item: pytest.FixtureRequest | pytest.Item) -> bool:
"""Returns whether the request or item is a Django test case."""
from django.test import SimpleTestCase

cls = getattr(request_or_item, "cls", None)
Expand Down
8 changes: 4 additions & 4 deletions pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ def _live_server_helper(request: pytest.FixtureRequest) -> Generator[None, None,

@contextmanager
def _assert_num_queries(
config,
config: pytest.Config,
num: int,
exact: bool = True,
connection=None,
info=None,
info: str | None = None,
) -> Generator[django.test.utils.CaptureQueriesContext, None, None]:
from django.test.utils import CaptureQueriesContext

Expand Down Expand Up @@ -636,12 +636,12 @@ def _assert_num_queries(


@pytest.fixture()
def django_assert_num_queries(pytestconfig):
def django_assert_num_queries(pytestconfig: pytest.Config):
return partial(_assert_num_queries, pytestconfig)


@pytest.fixture()
def django_assert_max_num_queries(pytestconfig):
def django_assert_max_num_queries(pytestconfig: pytest.Config):
return partial(_assert_num_queries, pytestconfig, exact=False)


Expand Down

0 comments on commit 9047da6

Please sign in to comment.