Add new options, normalization, and empty result checks in assertQueries().
Review Request #12367 — Created June 14, 2022 and submitted
Information | |
---|---|
chipx86 | |
Djblets | |
release-3.x | |
Reviewers | |
djblets | |
This introduces the following new comparison keys in
TestCase.assertQueries()
:
limit
- The value for a SQLLIMIT
offset
- The value for a SQLOFFSET
select_for_update
- Whethermodel.select_for_update(...)
was usedvalues_select
- Any fields passed to.values()
or.value_list()
It also does a few other things to fix and aid in comparisons.
Any values in extra
are now normalized. Whitespace is collapsed and
stripped. Unit tests no longer have to be aware of the exact formatting
of the SQL, which helps for more complex statements.
Queries that are generated but not executed (any that would raise a
EmptyResultSet
) are now skipped for comparison. An example would be a
query on pk__in=[]
, which Django knows makes no sense to pass to the
database. This is a way that code can short-circuit and optimize out an
entire query or a particular clause of the query in Django.
assertQueries()
now ignores it just as Django does.
Made use of these in other unit tests.
Summary | |
---|---|
Description | From | Last Updated |
---|---|---|
I'm a little confused on this (particularly the Callers do not need to supply this default), maybe some rewording is … |
![]() |

-
-
djblets/testing/testcases.py (Diff revision 1) I'm a little confused on this (particularly the
Callers do not need to supply this default
), maybe some rewording is in order. Does this mean Django may use a value of 21 forLIMIT
even when thislimit
is setNone
?
Change Summary:
Took another stab at describing the
limit
option.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+234 -46) |