From 7cfa40d87286a7fb19331f856e25183a2f914b36 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 5 Oct 2020 11:50:21 +0200 Subject: [PATCH] Refs #32068 -- Added tests for get() following union(), intersection(), and difference(). --- tests/queries/test_qs_combinators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index d6a5667fe75..1029e40ed85 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -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]