From 50f71ccb366cc0642d5a78447b46037b2e0a66da Mon Sep 17 00:00:00 2001 From: Laurent Tramoy Date: Tue, 26 May 2020 08:50:19 +0200 Subject: [PATCH] Used operator.attrgetter() in test_qs_combinators. --- tests/queries/test_qs_combinators.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index d2e7d2b80d4..d034261e64f 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -1,3 +1,5 @@ +import operator + from django.db import DatabaseError, NotSupportedError, connection from django.db.models import Exists, F, IntegerField, OuterRef, Value from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature @@ -11,11 +13,8 @@ class QuerySetSetOperationTests(TestCase): def setUpTestData(cls): Number.objects.bulk_create(Number(num=i, other_num=10 - i) for i in range(10)) - def number_transform(self, value): - return value.num - def assertNumbersEqual(self, queryset, expected_numbers, ordered=True): - self.assertQuerysetEqual(queryset, expected_numbers, self.number_transform, ordered) + self.assertQuerysetEqual(queryset, expected_numbers, operator.attrgetter('num'), ordered) def test_simple_union(self): qs1 = Number.objects.filter(num__lte=1)