Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ValuesQuerySet in assertQuerySetEqual #197

Merged
merged 1 commit into from
Sep 26, 2023
Merged
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
23 changes: 22 additions & 1 deletion django-stubs/test/testcases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from django.core.servers.basehttp import ThreadedWSGIServer, WSGIRequestHandler
from django.db import connections as connections # noqa: F401
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models import Model
from django.db.models.query import _BaseQuerySet
from django.db.models.query import _BaseQuerySet, ValuesQuerySet
from django.forms.fields import EmailField
from django.http.response import HttpResponse, HttpResponseBase
from django.template.base import Template
Expand Down Expand Up @@ -165,13 +165,15 @@ class SimpleTestCase(unittest.TestCase):

_T = TypeVar("_T")
_M = TypeVar("_M", bound=Model)
_R = TypeVar("_R")

class TransactionTestCase(SimpleTestCase):
reset_sequences: bool = ...
available_apps: Any = ...
fixtures: Any = ...
multi_db: bool = ...
serialized_rollback: bool = ...
@overload
def assertQuerySetEqual(
self,
qs: _BaseQuerySet[_M],
Expand All @@ -180,7 +182,17 @@ class TransactionTestCase(SimpleTestCase):
ordered: bool = ...,
msg: str | None = ...,
) -> None: ...
@overload
def assertQuerySetEqual( # pyright: ignore[reportOverlappingOverload]
self,
qs: ValuesQuerySet[_M, _R],
values: Iterable[_T],
transform: Callable[[_R], _T] = ...,
ordered: bool = ...,
msg: str | None = ...,
) -> None: ...
# Deprecated alias to assertQuerySetEqual
@overload
def assertQuerysetEqual(
self,
qs: _BaseQuerySet[_M],
Expand All @@ -190,6 +202,15 @@ class TransactionTestCase(SimpleTestCase):
msg: str | None = ...,
) -> None: ...
@overload
def assertQuerysetEqual( # pyright: ignore[reportOverlappingOverload]
self,
qs: ValuesQuerySet[_M, _R],
values: Iterable[_T],
transform: Callable[[_R], _T] = ...,
ordered: bool = ...,
msg: str | None = ...,
) -> None: ...
@overload
def assertNumQueries(
self,
num: int,
Expand Down