Skip to content

Commit 50177bc

Browse files
committed
call filter once in each test
1 parent fafe479 commit 50177bc

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tests/lookup_/tests.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,19 @@ def setUpTestData(cls):
8888

8989
def _test_none_filter_nullable_json(self, op, predicate, field):
9090
with self.assertNumQueries(1) as ctx:
91-
list(NullableJSONModel.objects.filter(**{f"{field}__{op}": None}))
91+
self.assertQuerySetEqual(
92+
NullableJSONModel.objects.filter(**{f"{field}__{op}": None}),
93+
[],
94+
)
9295
self.assertAggregateQuery(
9396
ctx.captured_queries[0]["sql"],
9497
"lookup__nullablejsonmodel",
9598
[{"$match": {"$and": [{"$exists": False}, predicate(field)]}}],
9699
)
97-
self.assertQuerySetEqual(
98-
NullableJSONModel.objects.filter(**{f"{field}__{op}": None}),
99-
[],
100-
)
101100

102101
def _test_none_filter_binary_operator(self, op, predicate, field):
103102
with self.assertNumQueries(1) as ctx:
104-
list(Book.objects.filter(**{f"{field}__{op}": None}))
103+
self.assertQuerySetEqual(Book.objects.filter(**{f"{field}__{op}": None}), [])
105104
self.assertAggregateQuery(
106105
ctx.captured_queries[0]["sql"],
107106
"lookup__book",
@@ -116,7 +115,6 @@ def _test_none_filter_binary_operator(self, op, predicate, field):
116115
}
117116
],
118117
)
119-
self.assertQuerySetEqual(Book.objects.filter(**{f"{field}__{op}": None}), [])
120118

121119
def _test_with_raw_data(self, model, test_function):
122120
collection = connection.database.get_collection(model._meta.db_table)

0 commit comments

Comments
 (0)