Refs #32068 -- Added tests for get() following union(), intersection(), and difference().

This commit is contained in:
Hasan Ramezani 2020-10-05 11:50:21 +02:00 committed by Mariusz Felisiak
parent c32d8f33d8
commit 7cfa40d872
1 changed files with 16 additions and 0 deletions

View File

@ -227,6 +227,22 @@ class QuerySetSetOperationTests(TestCase):
qs2 = Number.objects.filter(num__lte=5)
self.assertEqual(qs1.intersection(qs2).count(), 1)
def test_get_union(self):
qs = Number.objects.filter(num=2)
self.assertEqual(qs.union(qs).get().num, 2)
@skipUnlessDBFeature('supports_select_difference')
def test_get_difference(self):
qs1 = Number.objects.all()
qs2 = Number.objects.exclude(num=2)
self.assertEqual(qs1.difference(qs2).get().num, 2)
@skipUnlessDBFeature('supports_select_intersection')
def test_get_intersection(self):
qs1 = Number.objects.all()
qs2 = Number.objects.filter(num=2)
self.assertEqual(qs1.intersection(qs2).get().num, 2)
@skipUnlessDBFeature('supports_slicing_ordering_in_compound')
def test_ordering_subqueries(self):
qs1 = Number.objects.order_by('num')[:2]