[Django] #31235: assertQuerysetEqual cannot compare querysets directly

10 views
Skip to first unread message

Django

unread,
Feb 4, 2020, 4:56:04 PM2/4/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly
---------------------------------------------+------------------------
Reporter: Peter Inglesby | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
As discussed briefly on django-dev [0] I'd like to modify
`assertQuerysetEqual` so that `assertQuerysetEqual(qs1, qs2)` works.

[0] https://groups.google.com/forum/?#!msg/django-
developers/wdO0e0835EY/X_D9gVe_EwAJ

--
Ticket URL: <https://code.djangoproject.com/ticket/31235>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 4, 2020, 10:43:37 PM2/4/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly
-----------------------------------+------------------------------------

Reporter: Peter Inglesby | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


Comment:

I think the suggested approach makes sense, I suggest we deprecate the
`repr` default entirely through a deprecation period.

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:1>

Django

unread,
Feb 5, 2020, 1:58:33 AM2/5/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Peter
| Inglesby
Type: New feature | Status: assigned
Component: Testing framework | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => assigned
* needs_better_patch: 0 => 1
* version: 3.0 => master
* owner: nobody => Peter Inglesby
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/12417 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:2>

Django

unread,
Oct 18, 2020, 1:58:44 PM10/18/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani

Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: Peter Inglesby => Hasan Ramezani
* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/13557 New PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:3>

Django

unread,
Oct 22, 2020, 6:56:24 AM10/22/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:4>

Django

unread,
Oct 22, 2020, 4:48:13 PM10/22/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

Mariusz:
I rebased the PR and changed a lot of assertions and remove `repr` from
`assertQuerysetEqual`.
There are some assertions that are using `repr`. most of them are for
models that use more than one field in `__str__`.

like:
* https://github.com/django/django/pull/13557/files#diff-
ad6ec549eed244cc16532a3944710bfee97faeba6e3d21fbea58a5cb544254d2R1013
* https://github.com/django/django/pull/13557/files#diff-
ad3486daf49a0018f6d9202fbdaf3392dda74e2543decf9bdc43f37d2ebec8b2R221

I think we can keep them as is. what do you think?

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:5>

Django

unread,
Oct 23, 2020, 7:59:27 AM10/23/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:6>

Django

unread,
Nov 6, 2020, 3:31:30 AM11/6/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:7>

Django

unread,
Nov 6, 2020, 5:30:59 AM11/6/20
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3f7b3275627385f8f7531fca01cdda50d4ec6b6e" 3f7b327]:
{{{
#!CommitTicketReference repository=""
revision="3f7b3275627385f8f7531fca01cdda50d4ec6b6e"
Fixed #31235 -- Made assertQuerysetEqual() compare querysets directly.

This also replaces assertQuerysetEqual() to
assertSequenceEqual()/assertCountEqual() where appropriate.

Co-authored-by: Peter Inglesby <peter.i...@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:8>

Django

unread,
Mar 10, 2021, 10:09:21 AM3/10/21
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: closed
Component: Testing framework | Version: dev

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"bc43ae7c13b903022ec1fcb4867f5f10d7f125d6" bc43ae7]:
{{{
#!CommitTicketReference repository=""
revision="bc43ae7c13b903022ec1fcb4867f5f10d7f125d6"
Refs #31235 -- Improved assertQuerysetEqual() warning message with
stacklevel=2.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:9>

Django

unread,
Mar 10, 2021, 10:13:53 AM3/10/21
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: closed
Component: Testing framework | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"104d6172e85101658147a568de86bb678fa1c019" 104d6172]:
{{{
#!CommitTicketReference repository=""
revision="104d6172e85101658147a568de86bb678fa1c019"
[3.2.x] Refs #31235 -- Improved assertQuerysetEqual() warning message with
stacklevel=2.

Backport of bc43ae7c13b903022ec1fcb4867f5f10d7f125d6 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:10>

Django

unread,
Sep 20, 2021, 3:23:15 PM9/20/21
to django-...@googlegroups.com
#31235: assertQuerysetEqual cannot compare querysets directly.
-------------------------------------+-------------------------------------
Reporter: Peter Inglesby | Owner: Hasan
| Ramezani
Type: New feature | Status: closed
Component: Testing framework | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"e2be307b3ab6ebf339b3a765fe64967c9602266f" e2be307]:
{{{
#!CommitTicketReference repository=""
revision="e2be307b3ab6ebf339b3a765fe64967c9602266f"
Refs #31235 -- Made assertQuerysetEqual() not call repr() on a queryset
when compared to string values.

Per deprecation timeline.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31235#comment:11>

Reply all
Reply to author
Forward
0 new messages