MCPcopy
hub / github.com/django/django / test_combining_does_not_mutate

Method test_combining_does_not_mutate

tests/queries/tests.py:1361–1377  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1359 self.assertSequenceEqual(Note.objects.exclude(negate=True), [self.n3])
1360
1361 def test_combining_does_not_mutate(self):
1362 all_authors = Author.objects.all()
1363 authors_with_report = Author.objects.filter(
1364 Exists(Report.objects.filter(creator__pk=OuterRef("id")))
1365 )
1366 authors_without_report = all_authors.exclude(pk__in=authors_with_report)
1367 items_before = Item.objects.filter(creator__in=authors_without_report)
1368 self.assertCountEqual(items_before, [self.i2, self.i3, self.i4])
1369 # Combining querysets doesn't mutate them.
1370 all_authors | authors_with_report
1371 all_authors & authors_with_report
1372
1373 authors_without_report = all_authors.exclude(pk__in=authors_with_report)
1374 items_after = Item.objects.filter(creator__in=authors_without_report)
1375
1376 self.assertCountEqual(items_after, [self.i2, self.i3, self.i4])
1377 self.assertCountEqual(items_before, items_after)
1378
1379 @skipUnlessDBFeature("supports_select_union")
1380 def test_union_values_subquery(self):

Callers

nothing calls this directly

Calls 5

ExistsClass · 0.90
OuterRefClass · 0.90
excludeMethod · 0.80
allMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected