From f0c06f8ab7904e1fd082f2de57337f6c7e05f177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20G=C3=A4rtner?= Date: Sat, 24 Sep 2022 11:29:58 +0100 Subject: [PATCH] Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to assertQuerySetEqual(). Co-Authored-By: Michael Howitz --- django/test/testcases.py | 11 +- docs/internals/deprecation.txt | 2 + docs/intro/tutorial05.txt | 12 +- docs/releases/1.6.txt | 2 +- docs/releases/3.2.txt | 3 +- docs/releases/4.2.txt | 3 + docs/topics/testing/tools.txt | 9 +- tests/aggregation/tests.py | 54 +++---- tests/aggregation_regress/tests.py | 52 +++--- tests/annotations/tests.py | 20 +-- tests/basic/tests.py | 2 +- tests/bulk_create/tests.py | 10 +- tests/custom_columns/tests.py | 2 +- tests/custom_lookups/tests.py | 2 +- tests/custom_managers/tests.py | 92 +++++------ tests/custom_methods/tests.py | 8 +- tests/custom_pk/tests.py | 12 +- .../db_functions/comparison/test_coalesce.py | 12 +- .../datetime/test_extract_trunc.py | 122 +++++++------- tests/db_functions/datetime/test_now.py | 4 +- tests/db_functions/tests.py | 12 +- tests/db_functions/text/test_concat.py | 4 +- tests/db_functions/text/test_left.py | 6 +- tests/db_functions/text/test_length.py | 6 +- tests/db_functions/text/test_lower.py | 6 +- tests/db_functions/text/test_pad.py | 4 +- tests/db_functions/text/test_repeat.py | 2 +- tests/db_functions/text/test_replace.py | 10 +- tests/db_functions/text/test_reverse.py | 2 +- tests/db_functions/text/test_right.py | 6 +- tests/db_functions/text/test_strindex.py | 12 +- tests/db_functions/text/test_substr.py | 8 +- tests/db_functions/text/test_trim.py | 4 +- tests/db_functions/text/test_upper.py | 6 +- tests/defer/tests.py | 2 +- tests/defer_regress/tests.py | 2 +- tests/expressions/tests.py | 20 +-- tests/expressions_case/tests.py | 152 +++++++++--------- tests/expressions_window/tests.py | 72 ++++----- tests/extra_regress/tests.py | 8 +- tests/filtered_relation/tests.py | 16 +- tests/fixtures/tests.py | 14 +- tests/fixtures_model_package/tests.py | 8 +- tests/fixtures_regress/tests.py | 4 +- .../test_agnostic_order_trimjoin.py | 4 +- tests/foreign_object/tests.py | 32 ++-- tests/generic_relations/tests.py | 10 +- tests/generic_views/test_edit.py | 34 ++-- tests/gis_tests/geoapp/tests.py | 4 +- tests/lookup/tests.py | 42 ++--- tests/m2m_and_m2o/tests.py | 14 +- tests/m2m_intermediary/tests.py | 4 +- tests/m2m_multiple/tests.py | 22 +-- tests/m2m_through/tests.py | 46 +++--- tests/many_to_one/tests.py | 2 +- tests/model_fields/test_jsonfield.py | 4 +- tests/model_formsets/tests.py | 2 +- tests/model_formsets_regress/tests.py | 2 +- tests/model_inheritance/tests.py | 22 +-- tests/model_inheritance_regress/tests.py | 6 +- tests/model_regress/tests.py | 20 +-- tests/multiple_database/tests.py | 4 +- tests/null_fk/tests.py | 4 +- tests/or_lookups/tests.py | 44 ++--- tests/order_with_respect_to/base_tests.py | 4 +- tests/order_with_respect_to/tests.py | 2 +- tests/ordering/tests.py | 70 ++++---- tests/postgres_tests/test_trigram.py | 6 +- tests/postgres_tests/test_unaccent.py | 10 +- tests/queries/test_qs_combinators.py | 10 +- tests/queries/tests.py | 46 +++--- tests/save_delete_hooks/tests.py | 4 +- tests/servers/tests.py | 2 +- tests/signals/tests.py | 2 +- tests/test_utils/tests.py | 39 +++-- tests/timezones/tests.py | 12 +- 76 files changed, 689 insertions(+), 660 deletions(-) diff --git a/django/test/testcases.py b/django/test/testcases.py index 871f141725..a9349d82f1 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1322,7 +1322,16 @@ class TransactionTestCase(SimpleTestCase): inhibit_post_migrate=inhibit_post_migrate, ) - def assertQuerysetEqual(self, qs, values, transform=None, ordered=True, msg=None): + # RemovedInDjango51Warning. + def assertQuerysetEqual(self, *args, **kw): + warnings.warn( + "assertQuerysetEqual() is deprecated in favor of assertQuerySetEqual().", + category=RemovedInDjango51Warning, + stacklevel=2, + ) + return self.assertQuerySetEqual(*args, **kw) + + def assertQuerySetEqual(self, qs, values, transform=None, ordered=True, msg=None): values = list(values) items = qs if transform is not None: diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index cbde99fb06..abd5a363bc 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -37,6 +37,8 @@ details on these changes. * The ``SimpleTestCase.assertFormsetError()`` method will be removed. +* The ``TransactionTestCase.assertQuerysetEqual()`` method will be removed. + .. _deprecation-removed-in-5.0: 5.0 diff --git a/docs/intro/tutorial05.txt b/docs/intro/tutorial05.txt index 4a453a83b6..4431af71ad 100644 --- a/docs/intro/tutorial05.txt +++ b/docs/intro/tutorial05.txt @@ -491,7 +491,7 @@ class: response = self.client.get(reverse('polls:index')) self.assertEqual(response.status_code, 200) self.assertContains(response, "No polls are available.") - self.assertQuerysetEqual(response.context['latest_question_list'], []) + self.assertQuerySetEqual(response.context['latest_question_list'], []) def test_past_question(self): """ @@ -500,7 +500,7 @@ class: """ question = create_question(question_text="Past question.", days=-30) response = self.client.get(reverse('polls:index')) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context['latest_question_list'], [question], ) @@ -513,7 +513,7 @@ class: create_question(question_text="Future question.", days=30) response = self.client.get(reverse('polls:index')) self.assertContains(response, "No polls are available.") - self.assertQuerysetEqual(response.context['latest_question_list'], []) + self.assertQuerySetEqual(response.context['latest_question_list'], []) def test_future_question_and_past_question(self): """ @@ -523,7 +523,7 @@ class: question = create_question(question_text="Past question.", days=-30) create_question(question_text="Future question.", days=30) response = self.client.get(reverse('polls:index')) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context['latest_question_list'], [question], ) @@ -535,7 +535,7 @@ class: question1 = create_question(question_text="Past question 1.", days=-30) question2 = create_question(question_text="Past question 2.", days=-5) response = self.client.get(reverse('polls:index')) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context['latest_question_list'], [question2, question1], ) @@ -551,7 +551,7 @@ repetition out of the process of creating questions. Note that the :class:`django.test.TestCase` class provides some additional assertion methods. In these examples, we use :meth:`~django.test.SimpleTestCase.assertContains()` and -:meth:`~django.test.TransactionTestCase.assertQuerysetEqual()`. +:meth:`~django.test.TransactionTestCase.assertQuerySetEqual()`. In ``test_past_question``, we create a question and verify that it appears in the list. diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt index 2d77c7dc85..ac3b46ab3a 100644 --- a/docs/releases/1.6.txt +++ b/docs/releases/1.6.txt @@ -162,7 +162,7 @@ Minor features * The ``HttpOnly`` flag can be set on the CSRF cookie with :setting:`CSRF_COOKIE_HTTPONLY`. -* The :meth:`~django.test.TransactionTestCase.assertQuerysetEqual` now checks +* The ``assertQuerysetEqual()`` now checks for undefined order and raises :exc:`ValueError` if undefined order is spotted. The order is seen as undefined if the given ``QuerySet`` isn't ordered and there is more than one ordered value to compare against. diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 15a079988d..0195e3cf6e 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -539,7 +539,8 @@ Tests ` in a list. This allows you to test such callbacks without using the slower :class:`.TransactionTestCase`. -* :meth:`.TransactionTestCase.assertQuerysetEqual` now supports direct +* :meth:`TransactionTestCase.assertQuerysetEqual() + ` now supports direct comparison against another queryset rather than being restricted to comparison against a list of string representations of objects when using the default value for the ``transform`` argument. diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 33035d7881..c3ddb7c7af 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -422,3 +422,6 @@ Miscellaneous * ``SimpleTestCase.assertFormsetError()`` is deprecated in favor of ``assertFormSetError()``. + +* ``TransactionTestCase.assertQuerysetEqual()`` is deprecated in favor of + ``assertQuerySetEqual()``. diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 4e2003acde..0eb6fee113 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -787,7 +787,7 @@ add some database-specific features: * Database :attr:`~TransactionTestCase.fixtures`. * Test :ref:`skipping based on database backend features `. * The remaining specialized :meth:`assert* - ` methods. + ` methods. Django's :class:`TestCase` class is a more commonly used subclass of ``TransactionTestCase`` that makes use of database transaction facilities @@ -1777,7 +1777,7 @@ your test suite. Output in case of error can be customized with the ``msg`` argument. -.. method:: TransactionTestCase.assertQuerysetEqual(qs, values, transform=None, ordered=True, msg=None) +.. method:: TransactionTestCase.assertQuerySetEqual(qs, values, transform=None, ordered=True, msg=None) Asserts that a queryset ``qs`` matches a particular iterable of values ``values``. @@ -1794,6 +1794,11 @@ your test suite. Output in case of error can be customized with the ``msg`` argument. + .. deprecated:: 4.2 + + The ``assertQuerysetEqual()`` assertion method is deprecated. Use + ``assertQuerySetEqual()`` instead. + .. method:: TransactionTestCase.assertNumQueries(num, func, *args, **kwargs) Asserts that when ``func`` is called with ``*args`` and ``**kwargs`` that diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index be4e557c8f..39c8a45707 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -240,7 +240,7 @@ class AggregateTestCase(TestCase): self.assertEqual(vals, {"min_year": 1991}) def test_annotate_basic(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Book.objects.annotate().order_by("pk"), [ "The Definitive Guide to Django: Web Development Done Right", @@ -276,7 +276,7 @@ class AggregateTestCase(TestCase): "The Definitive Guide to Django: Web Development Done Right", ) ] - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.order_by("pk"), rows, lambda r: (r.id, r.isbn, r.page_sum, r.name) ) @@ -297,7 +297,7 @@ class AggregateTestCase(TestCase): "The Definitive Guide to Django: Web Development Done Right", ) ] - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.order_by("pk"), rows, lambda r: (r.id, r.isbn, r.page_sum, r.contact.name, r.name), @@ -309,7 +309,7 @@ class AggregateTestCase(TestCase): .annotate(Avg("authors__age")) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ ("Artificial Intelligence: A Modern Approach", 51.5), @@ -321,7 +321,7 @@ class AggregateTestCase(TestCase): ) books = Book.objects.annotate(num_authors=Count("authors")).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ ("Artificial Intelligence: A Modern Approach", 2), @@ -344,7 +344,7 @@ class AggregateTestCase(TestCase): .annotate(Avg("book__rating")) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("Adrian Holovaty", 4.5), @@ -358,7 +358,7 @@ class AggregateTestCase(TestCase): ) authors = Author.objects.annotate(num_books=Count("book")).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("Adrian Holovaty", 1), @@ -376,7 +376,7 @@ class AggregateTestCase(TestCase): def test_reverse_fkey_annotate(self): books = Book.objects.annotate(Sum("publisher__num_awards")).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ ("Artificial Intelligence: A Modern Approach", 7), @@ -394,7 +394,7 @@ class AggregateTestCase(TestCase): ) publishers = Publisher.objects.annotate(Sum("book__price")).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, [ ("Apress", Decimal("59.69")), @@ -515,7 +515,7 @@ class AggregateTestCase(TestCase): ) authors = Author.objects.annotate(Avg("friends__age")).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("Adrian Holovaty", 32.0), @@ -709,7 +709,7 @@ class AggregateTestCase(TestCase): .filter(num_books__gt=1) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, ["Apress", "Prentice Hall", "Expensive Publisher"], lambda p: p.name, @@ -718,7 +718,7 @@ class AggregateTestCase(TestCase): publishers = Publisher.objects.filter(book__price__lt=Decimal("40.0")).order_by( "pk" ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, [ "Apress", @@ -735,7 +735,7 @@ class AggregateTestCase(TestCase): .filter(num_books__gt=1, book__price__lt=Decimal("40.0")) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, ["Apress", "Prentice Hall", "Expensive Publisher"], lambda p: p.name, @@ -747,14 +747,14 @@ class AggregateTestCase(TestCase): .filter(num_books__gt=1) .order_by("pk") ) - self.assertQuerysetEqual(publishers, ["Apress"], lambda p: p.name) + self.assertQuerySetEqual(publishers, ["Apress"], lambda p: p.name) publishers = ( Publisher.objects.annotate(num_books=Count("book")) .filter(num_books__range=[1, 3]) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, [ "Apress", @@ -771,7 +771,7 @@ class AggregateTestCase(TestCase): .filter(num_books__range=[1, 2]) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, ["Apress", "Sams", "Prentice Hall", "Morgan Kaufmann"], lambda p: p.name, @@ -782,7 +782,7 @@ class AggregateTestCase(TestCase): .filter(num_books__in=[1, 3]) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, ["Sams", "Morgan Kaufmann", "Expensive Publisher"], lambda p: p.name, @@ -802,7 +802,7 @@ class AggregateTestCase(TestCase): .filter(num_authors__exact=2) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ "The Definitive Guide to Django: Web Development Done Right", @@ -816,14 +816,14 @@ class AggregateTestCase(TestCase): .filter(num_friends=0) .order_by("pk") ) - self.assertQuerysetEqual(authors, ["Brad Dayley"], lambda a: a.name) + self.assertQuerySetEqual(authors, ["Brad Dayley"], lambda a: a.name) publishers = ( Publisher.objects.annotate(num_books=Count("book__id")) .filter(num_books__gt=1) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( publishers, ["Apress", "Prentice Hall"], lambda p: p.name ) @@ -832,12 +832,12 @@ class AggregateTestCase(TestCase): .annotate(num_books=Count("book__id")) .filter(num_books__gt=1) ) - self.assertQuerysetEqual(publishers, ["Apress"], lambda p: p.name) + self.assertQuerySetEqual(publishers, ["Apress"], lambda p: p.name) books = Book.objects.annotate(num_authors=Count("authors__id")).filter( authors__name__contains="Norvig", num_authors__gt=1 ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, ["Artificial Intelligence: A Modern Approach"], lambda b: b.name ) @@ -1002,7 +1002,7 @@ class AggregateTestCase(TestCase): # Try to generate query tree str(excluded_books.query) - self.assertQuerysetEqual(excluded_books, all_books, lambda x: x.pk) + self.assertQuerySetEqual(excluded_books, all_books, lambda x: x.pk) # Check internal state self.assertIsNone(annotated_books.query.alias_map["aggregation_book"].join_type) @@ -1086,7 +1086,7 @@ class AggregateTestCase(TestCase): combined_ages=Sum("age") + Sum("friends__age") ).order_by("name") for qs in (authors, authors2): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Adrian Holovaty", 132), @@ -1381,7 +1381,7 @@ class AggregateTestCase(TestCase): .filter(price_or_median__gte=F("num_awards")) .order_by("num_awards") ) - self.assertQuerysetEqual(qs, [1, 3, 7, 9], lambda v: v.num_awards) + self.assertQuerySetEqual(qs, [1, 3, 7, 9], lambda v: v.num_awards) qs2 = ( Publisher.objects.annotate( @@ -1392,7 +1392,7 @@ class AggregateTestCase(TestCase): .filter(rating_or_num_awards__gt=F("num_awards")) .order_by("num_awards") ) - self.assertQuerysetEqual(qs2, [1, 3], lambda v: v.num_awards) + self.assertQuerySetEqual(qs2, [1, 3], lambda v: v.num_awards) def test_arguments_must_be_expressions(self): msg = "QuerySet.aggregate() received non-expression(s): %s." @@ -1692,7 +1692,7 @@ class AggregateTestCase(TestCase): def test_aggregation_random_ordering(self): """Random() is not included in the GROUP BY when used for ordering.""" authors = Author.objects.annotate(contact_count=Count("book")).order_by("?") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("Adrian Holovaty", 1), diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index e00aea0909..d3d06fe076 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -828,7 +828,7 @@ class AggregationTests(TestCase): # Regression for #10113 - Fields mentioned in order_by() must be # included in the GROUP BY. This only becomes a problem when the # order_by introduces a new join. - self.assertQuerysetEqual( + self.assertQuerySetEqual( Book.objects.annotate(num_authors=Count("authors")).order_by( "publisher__name", "name" ), @@ -851,7 +851,7 @@ class AggregationTests(TestCase): .annotate(Avg("authors__age")) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ( @@ -914,7 +914,7 @@ class AggregationTests(TestCase): .filter(n_authors__gt=2) .order_by("n_authors") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Book.objects.filter(id__in=ids), [ "Python Web Development with Django", @@ -1023,7 +1023,7 @@ class AggregationTests(TestCase): # the original query can still be used books = Book.objects.all() books.aggregate(Avg("authors__age")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books.all(), [ "Artificial Intelligence: A Modern Approach", @@ -1059,7 +1059,7 @@ class AggregationTests(TestCase): .order_by("sheets") .values("sheets") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [150, 175, 224, 264, 473, 566], lambda b: int(b["sheets"]) ) @@ -1084,7 +1084,7 @@ class AggregationTests(TestCase): self.assertEqual(sorted(p.name for p in publishers), ["Apress", "Sams"]) books = Book.objects.filter(publisher__in=publishers) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ "Practical Django Projects", @@ -1190,7 +1190,7 @@ class AggregationTests(TestCase): .filter(pages__lt=F("n_authors") * 200) .values_list("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Book.objects.filter(pk__in=qs), ["Python Web Development with Django"], attrgetter("name"), @@ -1239,7 +1239,7 @@ class AggregationTests(TestCase): .filter(Q(n_authors=2) | Q(name="Python Web Development with Django")) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "Artificial Intelligence: A Modern Approach", @@ -1258,7 +1258,7 @@ class AggregationTests(TestCase): ) ) ).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "The Definitive Guide to Django: Web Development Done Right", @@ -1273,7 +1273,7 @@ class AggregationTests(TestCase): .filter(Q(rating_sum__gt=5.5) | Q(rating_sum__isnull=True)) .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "Apress", @@ -1290,7 +1290,7 @@ class AggregationTests(TestCase): .filter(Q(rating_sum__gt=F("book_count")) | Q(rating_sum=None)) .order_by("num_awards") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "Jonno's House of Books", @@ -1308,7 +1308,7 @@ class AggregationTests(TestCase): .annotate(authorCount=Count("authors")) .order_by("authorCount") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Python Web Development with Django", 3), @@ -1387,14 +1387,14 @@ class AggregationTests(TestCase): .filter(book_cnt=2) .order_by("name") ) - self.assertQuerysetEqual(qs, ["Peter Norvig"], lambda b: b.name) + self.assertQuerySetEqual(qs, ["Peter Norvig"], lambda b: b.name) # Neither in this case qs = ( Author.objects.annotate(book_count=Count("book")) .filter(book_count=2) .order_by("name") ) - self.assertQuerysetEqual(qs, ["Peter Norvig"], lambda b: b.name) + self.assertQuerySetEqual(qs, ["Peter Norvig"], lambda b: b.name) # This case used to fail because the ORM couldn't resolve the # automatically generated annotation name `book__count` qs = ( @@ -1402,7 +1402,7 @@ class AggregationTests(TestCase): .filter(book__count=2) .order_by("name") ) - self.assertQuerysetEqual(qs, ["Peter Norvig"], lambda b: b.name) + self.assertQuerySetEqual(qs, ["Peter Norvig"], lambda b: b.name) # Referencing the auto-generated name in an aggregate() also works. self.assertEqual( Author.objects.annotate(Count("book")).aggregate(Max("book__count")), @@ -1570,7 +1570,7 @@ class AggregationTests(TestCase): self.assertEqual(len(grouping), 2) self.assertIn("id", grouping[0][0]) self.assertIn("id", grouping[1][0]) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.order_by("name"), [ ("Artificial Intelligence: A Modern Approach", 2), @@ -1659,7 +1659,7 @@ class AggregationTests(TestCase): .exclude(Q(book_cnt=2), Q(book_cnt=2)) .order_by("name") ) - self.assertQuerysetEqual(qs, expected_results, lambda b: b.name) + self.assertQuerySetEqual(qs, expected_results, lambda b: b.name) expected_results = Author.objects.exclude( pk__in=Author.objects.annotate(book_cnt=Count("book")).filter(book_cnt=2) ).order_by("name") @@ -1669,7 +1669,7 @@ class AggregationTests(TestCase): .exclude(Q(book_cnt=2) | Q(book_cnt=2)) .order_by("name") ) - self.assertQuerysetEqual(qs, expected_results, lambda b: b.name) + self.assertQuerySetEqual(qs, expected_results, lambda b: b.name) def test_name_filters(self): qs = ( @@ -1677,7 +1677,7 @@ class AggregationTests(TestCase): .filter(Q(book__count__exact=2) | Q(name="Adrian Holovaty")) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, ["Adrian Holovaty", "Peter Norvig"], lambda b: b.name ) @@ -1690,7 +1690,7 @@ class AggregationTests(TestCase): .filter(Q(name="Peter Norvig") | Q(age=F("book__count") + 33)) .order_by("name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, ["Adrian Holovaty", "Peter Norvig"], lambda b: b.name ) @@ -1698,7 +1698,7 @@ class AggregationTests(TestCase): q1 = Q(price__gt=50) q2 = Q(authors__count__gt=1) query = Book.objects.annotate(Count("authors")).filter(q1 | q2).order_by("pk") - self.assertQuerysetEqual( + self.assertQuerySetEqual( query, [self.b1.pk, self.b4.pk, self.b5.pk, self.b6.pk], attrgetter("pk"), @@ -1710,7 +1710,7 @@ class AggregationTests(TestCase): query = ( Book.objects.annotate(Count("authors")).filter(~(q1 & q2)).order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( query, [self.b1.pk, self.b2.pk, self.b3.pk, self.b4.pk, self.b6.pk], attrgetter("pk"), @@ -1720,7 +1720,7 @@ class AggregationTests(TestCase): q1 = Q(price__gt=50) q2 = Q(authors__count__gt=1) query = Book.objects.annotate(Count("authors")).filter(q1 ^ q2).order_by("pk") - self.assertQuerysetEqual( + self.assertQuerySetEqual( query, [self.b1.pk, self.b4.pk, self.b6.pk], attrgetter("pk"), @@ -1732,7 +1732,7 @@ class AggregationTests(TestCase): query = ( Book.objects.annotate(Count("authors")).filter(~(q1 ^ q2)).order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( query, [self.b2.pk, self.b3.pk, self.b5.pk], attrgetter("pk"), @@ -1756,7 +1756,7 @@ class AggregationTests(TestCase): qs = Book.objects.annotate(account=Count("authors")).filter( account=F("publisher__num_awards") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, ["Sams Teach Yourself Django in 24 Hours"], lambda b: b.name ) @@ -1873,7 +1873,7 @@ class SelfReferentialFKTests(TestCase): t1 = SelfRefFK.objects.create(name="t1") SelfRefFK.objects.create(name="t2", parent=t1) SelfRefFK.objects.create(name="t3", parent=t1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( SelfRefFK.objects.annotate(num_children=Count("children")).order_by("name"), [("t1", 2), ("t2", 0), ("t3", 0)], lambda x: (x.name, x.num_children), diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index 0a5bbd8a57..472669288c 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -517,7 +517,7 @@ class NonAggregateAnnotationTestCase(TestCase): .order_by("store_name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, ["Amazon.com", "Books.com", "Mamma and Pappa's Books"], lambda b: b.store_name, @@ -609,7 +609,7 @@ class NonAggregateAnnotationTestCase(TestCase): .filter(chain="Westfield") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Angus & Robinson", "Westfield", True, "155860191"), @@ -629,7 +629,7 @@ class NonAggregateAnnotationTestCase(TestCase): def test_order_by_annotation(self): authors = Author.objects.annotate(other_age=F("age")).order_by("other_age") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ 25, @@ -651,7 +651,7 @@ class NonAggregateAnnotationTestCase(TestCase): .annotate(age_count=Count("age")) .order_by("age_count", "age") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ (25, 1), @@ -735,7 +735,7 @@ class NonAggregateAnnotationTestCase(TestCase): (2, "Buffy", False, 42, "Summers", 18, Decimal(40000.00), store.name, 17), ] - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.order_by("id"), rows, lambda e: ( @@ -786,7 +786,7 @@ class NonAggregateAnnotationTestCase(TestCase): ] # and we respect deferred columns! - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.defer("age").order_by("id"), rows, lambda e: ( @@ -835,7 +835,7 @@ class NonAggregateAnnotationTestCase(TestCase): ) ).order_by("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Apple", "APPL"), @@ -891,7 +891,7 @@ class NonAggregateAnnotationTestCase(TestCase): # LOWER function supported by: # oracle, postgres, mysql, sqlite, sqlserver - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Apple", "APPL".lower()), @@ -1333,7 +1333,7 @@ class AliasTests(TestCase): def test_order_by_alias(self): qs = Author.objects.alias(other_age=F("age")).order_by("other_age") self.assertIs(hasattr(qs.first(), "other_age"), False) - self.assertQuerysetEqual(qs, [34, 34, 35, 46, 57], lambda a: a.age) + self.assertQuerySetEqual(qs, [34, 34, 35, 46, 57], lambda a: a.age) def test_order_by_alias_aggregate(self): qs = ( @@ -1342,7 +1342,7 @@ class AliasTests(TestCase): .order_by("age_count", "age") ) self.assertIs(hasattr(qs.first(), "age_count"), False) - self.assertQuerysetEqual(qs, [35, 46, 57, 34], lambda a: a["age"]) + self.assertQuerySetEqual(qs, [35, 46, 57, 34], lambda a: a["age"]) def test_dates_alias(self): qs = Book.objects.alias( diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 1d91e39ce9..899f1af83f 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -199,7 +199,7 @@ class ModelTest(TestCase): some_pub_date = datetime(2014, 5, 16, 12, 1) for headline in headlines: Article(headline=headline, pub_date=some_pub_date).save() - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("headline"), sorted(headlines), transform=lambda a: a.headline, diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index a01e50f4cb..bc2900110d 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -49,7 +49,7 @@ class BulkCreateTests(TestCase): def test_simple(self): created = Country.objects.bulk_create(self.data) self.assertEqual(created, self.data) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Country.objects.order_by("-name"), [ "United States of America", @@ -119,7 +119,7 @@ class BulkCreateTests(TestCase): Country(name="Tortall", iso_two_letter="TA"), ] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( ProxyCountry.objects.all(), {"Qwghlm", "Tortall"}, attrgetter("name"), @@ -131,7 +131,7 @@ class BulkCreateTests(TestCase): ProxyProxyCountry(name="Netherlands", iso_two_letter="NT"), ] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( ProxyProxyCountry.objects.all(), { "Qwghlm", @@ -146,7 +146,7 @@ class BulkCreateTests(TestCase): State.objects.bulk_create( [State(two_letter_code=s) for s in ["IL", "NY", "CA", "ME"]] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( State.objects.order_by("two_letter_code"), [ "CA", @@ -163,7 +163,7 @@ class BulkCreateTests(TestCase): State.objects.bulk_create( [State(two_letter_code=s) for s in ["IL", "NY", "CA", "ME"]] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( State.objects.order_by("two_letter_code"), [ "CA", diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py index 6d9e9f71cf..1b211b4c09 100644 --- a/tests/custom_columns/tests.py +++ b/tests/custom_columns/tests.py @@ -50,7 +50,7 @@ class CustomColumnsTests(TestCase): self.assertSequenceEqual(self.article.authors.all(), [self.a2, self.a1]) def test_get_all_articles_for_an_author(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.a1.article_set.all(), [ "Django lets you build web apps easily", diff --git a/tests/custom_lookups/tests.py b/tests/custom_lookups/tests.py index 7e5802a9a9..a636977b67 100644 --- a/tests/custom_lookups/tests.py +++ b/tests/custom_lookups/tests.py @@ -373,7 +373,7 @@ class BilateralTransformTests(TestCase): Author(name="Ray"), ] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.filter(name__upper__in=["foo", "bar", "doe"]).order_by( "name" ), diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py index 5ae5c719d8..b84b157da5 100644 --- a/tests/custom_managers/tests.py +++ b/tests/custom_managers/tests.py @@ -44,7 +44,7 @@ class CustomManagerTests(TestCase): """ Test a custom Manager method. """ - self.assertQuerysetEqual(Person.objects.get_fun_people(), ["Bugs Bunny"], str) + self.assertQuerySetEqual(Person.objects.get_fun_people(), ["Bugs Bunny"], str) def test_queryset_copied_to_default(self): """ @@ -83,7 +83,7 @@ class CustomManagerTests(TestCase): with self.subTest(manager_name=manager_name): manager = getattr(Person, manager_name) queryset = manager.filter() - self.assertQuerysetEqual(queryset, ["Bugs Bunny"], str) + self.assertQuerySetEqual(queryset, ["Bugs Bunny"], str) self.assertIs(queryset._filter_CustomQuerySet, True) # Specialized querysets inherit from our custom queryset. @@ -116,7 +116,7 @@ class CustomManagerTests(TestCase): Queryset method doesn't override the custom manager method. """ queryset = Person.custom_queryset_custom_manager.filter() - self.assertQuerysetEqual(queryset, ["Bugs Bunny"], str) + self.assertQuerySetEqual(queryset, ["Bugs Bunny"], str) self.assertIs(queryset._filter_CustomManager, True) def test_related_manager(self): @@ -139,7 +139,7 @@ class CustomManagerTests(TestCase): """ Custom managers respond to usual filtering methods """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Book.published_objects.all(), [ "How to program", @@ -161,7 +161,7 @@ class CustomManagerTests(TestCase): first_name="Droopy", last_name="Dog", fun=False, favorite_book=self.b1 ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books.order_by("first_name").all(), [ "Bugs", @@ -170,7 +170,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_people_favorite_books.all(), [ "Bugs", @@ -178,7 +178,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="boring_people").all(), [ "Droopy", @@ -186,7 +186,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="fun_people").all(), [ "Bugs", @@ -209,7 +209,7 @@ class CustomManagerTests(TestCase): first_name="Droopy", last_name="Dog", fun=False, favorite_thing=self.b1 ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things.all(), [ "Bugs", @@ -218,7 +218,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_people_favorite_things.all(), [ "Bugs", @@ -226,7 +226,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="boring_people").all(), [ "Droopy", @@ -234,7 +234,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="fun_people").all(), [ "Bugs", @@ -255,7 +255,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_authors.add(droopy) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors.order_by("first_name").all(), [ "Bugs", @@ -264,7 +264,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_authors.order_by("first_name").all(), [ "Bugs", @@ -272,7 +272,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="boring_people").all(), [ "Droopy", @@ -280,7 +280,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="fun_people").all(), [ "Bugs", @@ -298,7 +298,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_people_favorite_books.remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.filter(favorite_book=self.b1), [ "Bugs", @@ -309,7 +309,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_people_favorite_books.remove(bugs, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.filter(favorite_book=self.b1), [ "Droopy", @@ -321,7 +321,7 @@ class CustomManagerTests(TestCase): bugs.save() self.b1.fun_people_favorite_books.clear(bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.filter(favorite_book=self.b1), [ "Droopy", @@ -343,7 +343,7 @@ class CustomManagerTests(TestCase): # The fun manager DOESN'T remove boring people. self.b1.favorite_books(manager="fun_people").remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="boring_people").all(), [ "Droopy", @@ -353,7 +353,7 @@ class CustomManagerTests(TestCase): ) # The boring manager DOES remove boring people. self.b1.favorite_books(manager="boring_people").remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="boring_people").all(), [], lambda c: c.first_name, @@ -364,7 +364,7 @@ class CustomManagerTests(TestCase): # The fun manager ONLY clears fun people. self.b1.favorite_books(manager="fun_people").clear(bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="boring_people").all(), [ "Droopy", @@ -372,7 +372,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_books(manager="fun_people").all(), [], lambda c: c.first_name, @@ -391,7 +391,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_people_favorite_things.remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.order_by("first_name").filter( favorite_thing_id=self.b1.pk ), @@ -404,7 +404,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_people_favorite_things.remove(bugs, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.order_by("first_name").filter( favorite_thing_id=self.b1.pk ), @@ -418,7 +418,7 @@ class CustomManagerTests(TestCase): bugs.save() self.b1.fun_people_favorite_things.clear(bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FunPerson._base_manager.order_by("first_name").filter( favorite_thing_id=self.b1.pk ), @@ -442,7 +442,7 @@ class CustomManagerTests(TestCase): # The fun manager DOESN'T remove boring people. self.b1.favorite_things(manager="fun_people").remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="boring_people").all(), [ "Droopy", @@ -453,7 +453,7 @@ class CustomManagerTests(TestCase): # The boring manager DOES remove boring people. self.b1.favorite_things(manager="boring_people").remove(droopy, bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="boring_people").all(), [], lambda c: c.first_name, @@ -464,7 +464,7 @@ class CustomManagerTests(TestCase): # The fun manager ONLY clears fun people. self.b1.favorite_things(manager="fun_people").clear(bulk=bulk) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="boring_people").all(), [ "Droopy", @@ -472,7 +472,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.favorite_things(manager="fun_people").all(), [], lambda c: c.first_name, @@ -491,7 +491,7 @@ class CustomManagerTests(TestCase): self.b1.fun_authors.add(droopy) self.b1.fun_authors.remove(droopy) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_authors.through._default_manager.all(), [ "Bugs", @@ -502,7 +502,7 @@ class CustomManagerTests(TestCase): ) self.b1.fun_authors.remove(bugs) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_authors.through._default_manager.all(), [ "Droopy", @@ -513,7 +513,7 @@ class CustomManagerTests(TestCase): self.b1.fun_authors.add(bugs) self.b1.fun_authors.clear() - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.fun_authors.through._default_manager.all(), [ "Droopy", @@ -530,7 +530,7 @@ class CustomManagerTests(TestCase): # The fun manager DOESN'T remove boring people. self.b1.authors(manager="fun_people").remove(droopy) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="boring_people").all(), [ "Droopy", @@ -541,7 +541,7 @@ class CustomManagerTests(TestCase): # The boring manager DOES remove boring people. self.b1.authors(manager="boring_people").remove(droopy) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="boring_people").all(), [], lambda c: c.first_name, @@ -551,7 +551,7 @@ class CustomManagerTests(TestCase): # The fun manager ONLY clears fun people. self.b1.authors(manager="fun_people").clear() - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="boring_people").all(), [ "Droopy", @@ -559,7 +559,7 @@ class CustomManagerTests(TestCase): lambda c: c.first_name, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.b1.authors(manager="fun_people").all(), [], lambda c: c.first_name, @@ -628,7 +628,7 @@ class CustomManagerTests(TestCase): It will be inherited by the abstract model's children. """ PersonFromAbstract.abstract_persons.create(objects="Test") - self.assertQuerysetEqual( + self.assertQuerySetEqual( PersonFromAbstract.abstract_persons.all(), ["Test"], lambda c: c.objects, @@ -642,7 +642,7 @@ class TestCars(TestCase): Car.cars.create(name="Corvette", mileage=21, top_speed=180) Car.cars.create(name="Neon", mileage=31, top_speed=100) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Car._default_manager.order_by("name"), [ "Corvette", @@ -650,7 +650,7 @@ class TestCars(TestCase): ], lambda c: c.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Car.cars.order_by("name"), [ "Corvette", @@ -659,7 +659,7 @@ class TestCars(TestCase): lambda c: c.name, ) # alternate manager - self.assertQuerysetEqual( + self.assertQuerySetEqual( Car.fast_cars.all(), [ "Corvette", @@ -667,7 +667,7 @@ class TestCars(TestCase): lambda c: c.name, ) # explicit default manager - self.assertQuerysetEqual( + self.assertQuerySetEqual( FastCarAsDefault.cars.order_by("name"), [ "Corvette", @@ -675,7 +675,7 @@ class TestCars(TestCase): ], lambda c: c.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FastCarAsDefault._default_manager.all(), [ "Corvette", @@ -683,7 +683,7 @@ class TestCars(TestCase): lambda c: c.name, ) # explicit base manager - self.assertQuerysetEqual( + self.assertQuerySetEqual( FastCarAsBase.cars.order_by("name"), [ "Corvette", @@ -691,7 +691,7 @@ class TestCars(TestCase): ], lambda c: c.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( FastCarAsBase._base_manager.all(), [ "Corvette", @@ -779,4 +779,4 @@ class CustomManagersRegressTestCase(TestCase): """ qs_custom = Person.custom_init_queryset_manager.all() qs_default = Person.objects.all() - self.assertQuerysetEqual(qs_custom, qs_default) + self.assertQuerySetEqual(qs_custom, qs_default) diff --git a/tests/custom_methods/tests.py b/tests/custom_methods/tests.py index 2bae2d2623..43232e2132 100644 --- a/tests/custom_methods/tests.py +++ b/tests/custom_methods/tests.py @@ -15,14 +15,14 @@ class MethodsTests(TestCase): ) self.assertFalse(a.was_published_today()) - self.assertQuerysetEqual( + self.assertQuerySetEqual( a.articles_from_same_day_1(), [ "Beatles reunite", ], lambda a: a.headline, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( a.articles_from_same_day_2(), [ "Beatles reunite", @@ -30,14 +30,14 @@ class MethodsTests(TestCase): lambda a: a.headline, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( b.articles_from_same_day_1(), [ "Parrot programs in Python", ], lambda a: a.headline, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( b.articles_from_same_day_2(), [ "Parrot programs in Python", diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py index cb9fb02133..47838714ca 100644 --- a/tests/custom_pk/tests.py +++ b/tests/custom_pk/tests.py @@ -33,10 +33,10 @@ class BasicCustomPKTests(TestCase): ) self.assertSequenceEqual(Employee.objects.all(), [self.fran, self.dan]) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Business.objects.filter(name="Sears"), ["Sears"], lambda b: b.name ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Business.objects.filter(pk="Sears"), [ "Sears", @@ -52,7 +52,7 @@ class BasicCustomPKTests(TestCase): self.business.employees.all(), [self.fran, self.dan], ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.fran.business_set.all(), [ "Sears", @@ -73,14 +73,14 @@ class BasicCustomPKTests(TestCase): [self.fran, self.dan], ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Business.objects.filter(employees__employee_code=123), [ "Sears", ], lambda b: b.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Business.objects.filter(employees__pk=123), [ "Sears", @@ -88,7 +88,7 @@ class BasicCustomPKTests(TestCase): lambda b: b.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Business.objects.filter(employees__first_name__startswith="Fran"), [ "Sears", diff --git a/tests/db_functions/comparison/test_coalesce.py b/tests/db_functions/comparison/test_coalesce.py index d5f6a7a6a2..b08ae742df 100644 --- a/tests/db_functions/comparison/test_coalesce.py +++ b/tests/db_functions/comparison/test_coalesce.py @@ -15,7 +15,7 @@ class CoalesceTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.annotate(display_name=Coalesce("alias", "name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["smithj", "Rhonda"], lambda a: a.display_name ) @@ -39,7 +39,7 @@ class CoalesceTests(TestCase): article = Article.objects.annotate( headline=Coalesce("summary", "text", output_field=TextField()), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( article.order_by("title"), [lorem_ipsum], lambda a: a.headline ) # mixed Text and Char wrapped @@ -48,7 +48,7 @@ class CoalesceTests(TestCase): Lower("summary"), Lower("text"), output_field=TextField() ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( article.order_by("title"), [lorem_ipsum.lower()], lambda a: a.headline ) @@ -56,11 +56,11 @@ class CoalesceTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.order_by(Coalesce("alias", "name")) - self.assertQuerysetEqual(authors, ["Rhonda", "John Smith"], lambda a: a.name) + self.assertQuerySetEqual(authors, ["Rhonda", "John Smith"], lambda a: a.name) authors = Author.objects.order_by(Coalesce("alias", "name").asc()) - self.assertQuerysetEqual(authors, ["Rhonda", "John Smith"], lambda a: a.name) + self.assertQuerySetEqual(authors, ["Rhonda", "John Smith"], lambda a: a.name) authors = Author.objects.order_by(Coalesce("alias", "name").desc()) - self.assertQuerysetEqual(authors, ["John Smith", "Rhonda"], lambda a: a.name) + self.assertQuerySetEqual(authors, ["John Smith", "Rhonda"], lambda a: a.name) def test_empty_queryset(self): Author.objects.create(name="John Smith") diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py index 00e3897e68..2d38234981 100644 --- a/tests/db_functions/datetime/test_extract_trunc.py +++ b/tests/db_functions/datetime/test_extract_trunc.py @@ -277,21 +277,21 @@ class DateFunctionTests(TestCase): ): list(DTModel.objects.annotate(extracted=Extract("start_date", "second"))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "year") ).order_by("start_datetime"), [(start_datetime, start_datetime.year), (end_datetime, end_datetime.year)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "quarter") ).order_by("start_datetime"), [(start_datetime, 2), (end_datetime, 2)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "month") ).order_by("start_datetime"), @@ -301,21 +301,21 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "day") ).order_by("start_datetime"), [(start_datetime, start_datetime.day), (end_datetime, end_datetime.day)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "week") ).order_by("start_datetime"), [(start_datetime, 25), (end_datetime, 24)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "week_day") ).order_by("start_datetime"), @@ -325,7 +325,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "iso_week_day"), ).order_by("start_datetime"), @@ -335,14 +335,14 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "hour") ).order_by("start_datetime"), [(start_datetime, start_datetime.hour), (end_datetime, end_datetime.hour)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "minute") ).order_by("start_datetime"), @@ -352,7 +352,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=Extract("start_datetime", "second") ).order_by("start_datetime"), @@ -417,7 +417,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=Extract("duration", "second")).order_by( "start_datetime" ), @@ -465,14 +465,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractYear("start_datetime")).order_by( "start_datetime" ), [(start_datetime, start_datetime.year), (end_datetime, end_datetime.year)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractYear("start_date")).order_by( "start_datetime" ), @@ -494,14 +494,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractIsoYear("start_datetime") ).order_by("start_datetime"), [(start_datetime, start_datetime.year), (end_datetime, end_datetime.year)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractIsoYear("start_date")).order_by( "start_datetime" ), @@ -538,7 +538,7 @@ class DateFunctionTests(TestCase): ) .order_by("start_datetime") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (week_52_day_2014, 2014), @@ -569,7 +569,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractMonth("start_datetime")).order_by( "start_datetime" ), @@ -579,7 +579,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractMonth("start_date")).order_by( "start_datetime" ), @@ -604,14 +604,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractDay("start_datetime")).order_by( "start_datetime" ), [(start_datetime, start_datetime.day), (end_datetime, end_datetime.day)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractDay("start_date")).order_by( "start_datetime" ), @@ -633,14 +633,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractWeek("start_datetime")).order_by( "start_datetime" ), [(start_datetime, 25), (end_datetime, 24)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractWeek("start_date")).order_by( "start_datetime" ), @@ -663,14 +663,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractQuarter("start_datetime") ).order_by("start_datetime"), [(start_datetime, 2), (end_datetime, 3)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractQuarter("start_date")).order_by( "start_datetime" ), @@ -704,7 +704,7 @@ class DateFunctionTests(TestCase): ) .order_by("start_datetime") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (last_quarter_2014, 4), @@ -737,7 +737,7 @@ class DateFunctionTests(TestCase): ) .order_by("start_datetime") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (week_52_day_2014, 52), @@ -755,7 +755,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractWeekDay("start_datetime") ).order_by("start_datetime"), @@ -765,7 +765,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractWeekDay("start_date")).order_by( "start_datetime" ), @@ -790,7 +790,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractIsoWeekDay("start_datetime"), ).order_by("start_datetime"), @@ -800,7 +800,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractIsoWeekDay("start_date"), ).order_by("start_datetime"), @@ -825,14 +825,14 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractHour("start_datetime")).order_by( "start_datetime" ), [(start_datetime, start_datetime.hour), (end_datetime, end_datetime.hour)], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractHour("start_time")).order_by( "start_datetime" ), @@ -854,7 +854,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractMinute("start_datetime") ).order_by("start_datetime"), @@ -864,7 +864,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractMinute("start_time")).order_by( "start_datetime" ), @@ -889,7 +889,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( extracted=ExtractSecond("start_datetime") ).order_by("start_datetime"), @@ -899,7 +899,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=ExtractSecond("start_time")).order_by( "start_datetime" ), @@ -963,7 +963,7 @@ class DateFunctionTests(TestCase): self.create_model(end_datetime, start_datetime) def test_datetime_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc( "start_datetime", kind, output_field=DateTimeField() @@ -977,7 +977,7 @@ class DateFunctionTests(TestCase): ) def test_date_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc("start_date", kind, output_field=DateField()) ).order_by("start_datetime"), @@ -989,7 +989,7 @@ class DateFunctionTests(TestCase): ) def test_time_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc("start_time", kind, output_field=TimeField()) ).order_by("start_datetime"), @@ -1001,7 +1001,7 @@ class DateFunctionTests(TestCase): ) def test_datetime_to_time_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc("start_datetime", kind, output_field=TimeField()), ).order_by("start_datetime"), @@ -1044,7 +1044,7 @@ class DateFunctionTests(TestCase): self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc("start_datetime", "week", output_field=DateTimeField()) ).order_by("start_datetime"), @@ -1054,7 +1054,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.truncated), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc("start_date", "week", output_field=DateField()) ).order_by("start_datetime"), @@ -1137,7 +1137,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncYear("start_datetime")).order_by( "start_datetime" ), @@ -1147,7 +1147,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncYear("start_date")).order_by( "start_datetime" ), @@ -1194,7 +1194,7 @@ class DateFunctionTests(TestCase): self.create_model(start_datetime=end_datetime, end_datetime=start_datetime) self.create_model(start_datetime=last_quarter_2015, end_datetime=end_datetime) self.create_model(start_datetime=first_quarter_2016, end_datetime=end_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncQuarter("start_date")).order_by( "start_datetime" ), @@ -1206,7 +1206,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncQuarter("start_datetime")).order_by( "start_datetime" ), @@ -1241,7 +1241,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncMonth("start_datetime")).order_by( "start_datetime" ), @@ -1251,7 +1251,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncMonth("start_date")).order_by( "start_datetime" ), @@ -1288,7 +1288,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncWeek("start_datetime")).order_by( "start_datetime" ), @@ -1325,7 +1325,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncDate("start_datetime")).order_by( "start_datetime" ), @@ -1372,7 +1372,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncTime("start_datetime")).order_by( "start_datetime" ), @@ -1446,7 +1446,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncDay("start_datetime")).order_by( "start_datetime" ), @@ -1482,7 +1482,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncHour("start_datetime")).order_by( "start_datetime" ), @@ -1492,7 +1492,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncHour("start_time")).order_by( "start_datetime" ), @@ -1529,7 +1529,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncMinute("start_datetime")).order_by( "start_datetime" ), @@ -1539,7 +1539,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncMinute("start_time")).order_by( "start_datetime" ), @@ -1578,7 +1578,7 @@ class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncSecond("start_datetime")).order_by( "start_datetime" ), @@ -1588,7 +1588,7 @@ class DateFunctionTests(TestCase): ], lambda m: (m.start_datetime, m.extracted), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate(extracted=TruncSecond("start_time")).order_by( "start_datetime" ), @@ -1909,7 +1909,7 @@ class DateFunctionWithTimeZoneTests(DateFunctionTests): with self.subTest(repr(melb)): def test_datetime_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc( "start_datetime", @@ -1934,7 +1934,7 @@ class DateFunctionWithTimeZoneTests(DateFunctionTests): ) def test_datetime_to_date_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc( "start_datetime", @@ -1959,7 +1959,7 @@ class DateFunctionWithTimeZoneTests(DateFunctionTests): ) def test_datetime_to_time_kind(kind): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DTModel.objects.annotate( truncated=Trunc( "start_datetime", diff --git a/tests/db_functions/datetime/test_now.py b/tests/db_functions/datetime/test_now.py index 716c5744e9..64f56fdb58 100644 --- a/tests/db_functions/datetime/test_now.py +++ b/tests/db_functions/datetime/test_now.py @@ -39,12 +39,12 @@ class NowTests(TestCase): a2.save() a2.refresh_from_db() self.assertIsInstance(a2.published, datetime) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(published__lte=Now()), ["How to Django"], lambda a: a.title, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(published__gt=Now()), ["How to Time Travel"], lambda a: a.title, diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py index e5b73cdaac..5fb15d4fd9 100644 --- a/tests/db_functions/tests.py +++ b/tests/db_functions/tests.py @@ -17,7 +17,7 @@ class FunctionTests(TestCase): Author.objects.create(name="Rhonda Simpson", alias="ronny") authors = Author.objects.order_by(Length(Coalesce("alias", "name"))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ "Rhonda Simpson", @@ -27,7 +27,7 @@ class FunctionTests(TestCase): ) authors = Author.objects.order_by(Length(Coalesce("alias", "name")).desc()) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ "John Smith", @@ -41,7 +41,7 @@ class FunctionTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.filter(name__upper__exact="john smith") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "John Smith", @@ -54,7 +54,7 @@ class FunctionTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.filter(name__upper__in=["john smith", "rhonda"]) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "John Smith", @@ -66,12 +66,12 @@ class FunctionTests(TestCase): def test_function_as_filter(self): Author.objects.create(name="John Smith", alias="SMITHJ") Author.objects.create(name="Rhonda") - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.filter(alias=Upper(V("smithj"))), ["John Smith"], lambda x: x.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.exclude(alias=Upper(V("smithj"))), ["Rhonda"], lambda x: x.name, diff --git a/tests/db_functions/text/test_concat.py b/tests/db_functions/text/test_concat.py index 5932a9bed0..1441e31e97 100644 --- a/tests/db_functions/text/test_concat.py +++ b/tests/db_functions/text/test_concat.py @@ -21,7 +21,7 @@ class ConcatTests(TestCase): Author.objects.create(name="Margaret", goes_by="Maggie") Author.objects.create(name="Rhonda", alias="adnohR") authors = Author.objects.annotate(joined=Concat("alias", "goes_by")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "", @@ -46,7 +46,7 @@ class ConcatTests(TestCase): authors = Author.objects.annotate( joined=Concat("name", V(" ("), "goes_by", V(")"), output_field=CharField()), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "Jayden ()", diff --git a/tests/db_functions/text/test_left.py b/tests/db_functions/text/test_left.py index 8871f9ac79..aa2944c7e3 100644 --- a/tests/db_functions/text/test_left.py +++ b/tests/db_functions/text/test_left.py @@ -13,12 +13,12 @@ class LeftTests(TestCase): def test_basic(self): authors = Author.objects.annotate(name_part=Left("name", 5)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["John ", "Rhond"], lambda a: a.name_part ) # If alias is null, set it to the first 2 lower characters of the name. Author.objects.filter(alias__isnull=True).update(alias=Lower(Left("name", 2))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["smithj", "rh"], lambda a: a.alias ) @@ -30,6 +30,6 @@ class LeftTests(TestCase): authors = Author.objects.annotate( name_part=Left("name", Value(3, output_field=IntegerField())) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["Joh", "Rho"], lambda a: a.name_part ) diff --git a/tests/db_functions/text/test_length.py b/tests/db_functions/text/test_length.py index c6afead6aa..5fb2650beb 100644 --- a/tests/db_functions/text/test_length.py +++ b/tests/db_functions/text/test_length.py @@ -14,7 +14,7 @@ class LengthTests(TestCase): name_length=Length("name"), alias_length=Length("alias"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [(10, 6), (6, None)], lambda a: (a.name_length, a.alias_length), @@ -26,7 +26,7 @@ class LengthTests(TestCase): Author.objects.create(name="John Smith", alias="smithj1") Author.objects.create(name="Rhonda", alias="ronny") authors = Author.objects.order_by(Length("name"), Length("alias")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("Rhonda", "ronny"), @@ -41,6 +41,6 @@ class LengthTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.filter(name__length__gt=7) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["John Smith"], lambda a: a.name ) diff --git a/tests/db_functions/text/test_lower.py b/tests/db_functions/text/test_lower.py index f4bdc04573..a1feabc52a 100644 --- a/tests/db_functions/text/test_lower.py +++ b/tests/db_functions/text/test_lower.py @@ -11,11 +11,11 @@ class LowerTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.annotate(lower_name=Lower("name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["john smith", "rhonda"], lambda a: a.lower_name ) Author.objects.update(name=Lower("name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ ("john smith", "john smith"), @@ -35,6 +35,6 @@ class LowerTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.filter(name__lower__exact="john smith") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["John Smith"], lambda a: a.name ) diff --git a/tests/db_functions/text/test_pad.py b/tests/db_functions/text/test_pad.py index 006a27c0e8..6ae5e7496b 100644 --- a/tests/db_functions/text/test_pad.py +++ b/tests/db_functions/text/test_pad.py @@ -35,7 +35,7 @@ class PadTests(TestCase): for function, padded_name in tests: with self.subTest(function=function): authors = Author.objects.annotate(padded_name=function) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [padded_name], lambda a: a.padded_name, ordered=False ) @@ -51,7 +51,7 @@ class PadTests(TestCase): Author.objects.create(name="Rhonda", alias="john_smith") Author.objects.create(name="♥♣♠", alias="bytes") authors = Author.objects.annotate(filled=LPad("name", Length("alias"))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("alias"), [" ♥♣♠", " Rhonda"], lambda a: a.filled, diff --git a/tests/db_functions/text/test_repeat.py b/tests/db_functions/text/test_repeat.py index c2d21eae50..3a68958676 100644 --- a/tests/db_functions/text/test_repeat.py +++ b/tests/db_functions/text/test_repeat.py @@ -24,7 +24,7 @@ class RepeatTests(TestCase): for function, repeated_text in tests: with self.subTest(function=function): authors = Author.objects.annotate(repeated_text=function) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [repeated_text], lambda a: a.repeated_text, ordered=False ) diff --git a/tests/db_functions/text/test_replace.py b/tests/db_functions/text/test_replace.py index 28e39faf09..8b4d6ae9fe 100644 --- a/tests/db_functions/text/test_replace.py +++ b/tests/db_functions/text/test_replace.py @@ -15,7 +15,7 @@ class ReplaceTests(TestCase): qs = Author.objects.annotate( without_middlename=Replace(F("name"), Value("R. R. "), Value("")), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("George R. R. Martin", "George Martin"), @@ -29,7 +29,7 @@ class ReplaceTests(TestCase): qs = Author.objects.annotate( same_name=Replace(F("name"), Value("r. r."), Value("")) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("George R. R. Martin", "George R. R. Martin"), @@ -45,7 +45,7 @@ class ReplaceTests(TestCase): Concat(Value("Author: "), F("name")), Value("Author: "), Value("") ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("George R. R. Martin", "George R. R. Martin"), @@ -59,7 +59,7 @@ class ReplaceTests(TestCase): Author.objects.update( name=Replace(F("name"), Value("R. R. "), Value("")), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.all(), [ ("George Martin"), @@ -72,7 +72,7 @@ class ReplaceTests(TestCase): def test_replace_with_default_arg(self): # The default replacement is an empty string. qs = Author.objects.annotate(same_name=Replace(F("name"), Value("R. R. "))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("George R. R. Martin", "George Martin"), diff --git a/tests/db_functions/text/test_reverse.py b/tests/db_functions/text/test_reverse.py index 4d1a81ccf2..62d769d80c 100644 --- a/tests/db_functions/text/test_reverse.py +++ b/tests/db_functions/text/test_reverse.py @@ -25,7 +25,7 @@ class ReverseTests(TestCase): def test_basic(self): authors = Author.objects.annotate(backward=Reverse("name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors, [ ("John Smith", "htimS nhoJ"), diff --git a/tests/db_functions/text/test_right.py b/tests/db_functions/text/test_right.py index 8c271fcf7d..126f1583a5 100644 --- a/tests/db_functions/text/test_right.py +++ b/tests/db_functions/text/test_right.py @@ -13,12 +13,12 @@ class RightTests(TestCase): def test_basic(self): authors = Author.objects.annotate(name_part=Right("name", 5)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["Smith", "honda"], lambda a: a.name_part ) # If alias is null, set it to the first 2 lower characters of the name. Author.objects.filter(alias__isnull=True).update(alias=Lower(Right("name", 2))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["smithj", "da"], lambda a: a.alias ) @@ -30,6 +30,6 @@ class RightTests(TestCase): authors = Author.objects.annotate( name_part=Right("name", Value(3, output_field=IntegerField())) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["ith", "nda"], lambda a: a.name_part ) diff --git a/tests/db_functions/text/test_strindex.py b/tests/db_functions/text/test_strindex.py index 84305ea1b7..7120a6516e 100644 --- a/tests/db_functions/text/test_strindex.py +++ b/tests/db_functions/text/test_strindex.py @@ -12,7 +12,7 @@ class StrIndexTests(TestCase): Author.objects.create(name="J. R. R. Tolkien") Author.objects.create(name="Terry Pratchett") authors = Author.objects.annotate(fullstop=StrIndex("name", Value("R."))) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [9, 4, 0], lambda a: a.fullstop ) @@ -28,7 +28,7 @@ class StrIndexTests(TestCase): written=timezone.now(), ) articles = Article.objects.annotate(title_pos=StrIndex("text", "title")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( articles.order_by("title"), [15, 0], lambda a: a.title_pos ) @@ -36,7 +36,7 @@ class StrIndexTests(TestCase): Author.objects.create(name="Terry Pratchett") Author.objects.create(name="J. R. R. Tolkien") Author.objects.create(name="George. R. R. Martin") - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.order_by(StrIndex("name", Value("R.")).asc()), [ "Terry Pratchett", @@ -45,7 +45,7 @@ class StrIndexTests(TestCase): ], lambda a: a.name, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.order_by(StrIndex("name", Value("R.")).desc()), [ "George. R. R. Martin", @@ -60,12 +60,12 @@ class StrIndexTests(TestCase): Author.objects.create(name="皇帝") Author.objects.create(name="皇帝 ツリー") authors = Author.objects.annotate(sb=StrIndex("name", Value("リ"))) - self.assertQuerysetEqual(authors.order_by("name"), [2, 0, 5], lambda a: a.sb) + self.assertQuerySetEqual(authors.order_by("name"), [2, 0, 5], lambda a: a.sb) def test_filtering(self): Author.objects.create(name="George. R. R. Martin") Author.objects.create(name="Terry Pratchett") - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.annotate(middle_name=StrIndex("name", Value("R."))).filter( middle_name__gt=0 ), diff --git a/tests/db_functions/text/test_substr.py b/tests/db_functions/text/test_substr.py index 751995355c..702b40e8a9 100644 --- a/tests/db_functions/text/test_substr.py +++ b/tests/db_functions/text/test_substr.py @@ -10,18 +10,18 @@ class SubstrTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.annotate(name_part=Substr("name", 5, 3)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [" Sm", "da"], lambda a: a.name_part ) authors = Author.objects.annotate(name_part=Substr("name", 2)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["ohn Smith", "honda"], lambda a: a.name_part ) # If alias is null, set to first 5 lower characters of the name. Author.objects.filter(alias__isnull=True).update( alias=Lower(Substr("name", 1, 5)), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["smithj", "rhond"], lambda a: a.alias ) @@ -43,6 +43,6 @@ class SubstrTests(TestCase): Author.objects.create(name="Rhonda") substr = Substr(Upper("name"), StrIndex("name", V("h")), 5) authors = Author.objects.annotate(name_part=substr) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), ["HN SM", "HONDA"], lambda a: a.name_part ) diff --git a/tests/db_functions/text/test_trim.py b/tests/db_functions/text/test_trim.py index 57a342851e..e3d2e71ea5 100644 --- a/tests/db_functions/text/test_trim.py +++ b/tests/db_functions/text/test_trim.py @@ -15,7 +15,7 @@ class TrimTests(TestCase): rtrim=RTrim("name"), trim=Trim("name"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("alias"), [ ("John ", " John", "John"), @@ -38,4 +38,4 @@ class TrimTests(TestCase): authors = Author.objects.filter( **{"name__%s" % transform.lookup_name: trimmed_name} ) - self.assertQuerysetEqual(authors, [" John "], lambda a: a.name) + self.assertQuerySetEqual(authors, [" John "], lambda a: a.name) diff --git a/tests/db_functions/text/test_upper.py b/tests/db_functions/text/test_upper.py index 728ea82265..df1a616ad3 100644 --- a/tests/db_functions/text/test_upper.py +++ b/tests/db_functions/text/test_upper.py @@ -11,7 +11,7 @@ class UpperTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.annotate(upper_name=Upper("name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "JOHN SMITH", @@ -20,7 +20,7 @@ class UpperTests(TestCase): lambda a: a.upper_name, ) Author.objects.update(name=Upper("name")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ ("JOHN SMITH", "JOHN SMITH"), @@ -34,7 +34,7 @@ class UpperTests(TestCase): Author.objects.create(name="John Smith", alias="smithj") Author.objects.create(name="Rhonda") authors = Author.objects.filter(name__upper__exact="JOHN SMITH") - self.assertQuerysetEqual( + self.assertQuerySetEqual( authors.order_by("name"), [ "John Smith", diff --git a/tests/defer/tests.py b/tests/defer/tests.py index c2319b54ec..34544b4bef 100644 --- a/tests/defer/tests.py +++ b/tests/defer/tests.py @@ -144,7 +144,7 @@ class DeferTests(AssertionMixin, TestCase): obj = Primary.objects.defer("value").get(name="p2") obj.name = "a new name" obj.save() - self.assertQuerysetEqual( + self.assertQuerySetEqual( Primary.objects.all(), [ "p1", diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py index fb9dcdb297..9f94d5fac1 100644 --- a/tests/defer_regress/tests.py +++ b/tests/defer_regress/tests.py @@ -70,7 +70,7 @@ class DeferRegressionTest(TestCase): obj = Leaf.objects.only("name", "child").select_related()[0] self.assertEqual(obj.child.name, "c1") - self.assertQuerysetEqual( + self.assertQuerySetEqual( Leaf.objects.select_related().only("child__name", "second_child__name"), [ "l1", diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 7a759feda5..fd0094db63 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -248,7 +248,7 @@ class BasicExpressionsTests(TestCase): def test_update_with_fk(self): # ForeignKey can become updated with the value of another ForeignKey. self.assertEqual(Company.objects.update(point_of_contact=F("ceo")), 3) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Company.objects.all(), ["Joe Smith", "Frank Meyer", "Max Mustermann"], lambda c: str(c.point_of_contact), @@ -259,7 +259,7 @@ class BasicExpressionsTests(TestCase): Number.objects.create(integer=1, float=1.0) Number.objects.create(integer=2) Number.objects.filter(float__isnull=False).update(float=Value(None)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Number.objects.all(), [None, None], lambda n: n.float, ordered=False ) @@ -272,7 +272,7 @@ class BasicExpressionsTests(TestCase): ) c.save() - self.assertQuerysetEqual( + self.assertQuerySetEqual( Company.objects.filter(ceo__firstname=F("point_of_contact__firstname")), ["Foobar Ltd.", "Test GmbH"], lambda c: c.name, @@ -1027,7 +1027,7 @@ class IterableLookupInnerExpressionsTests(TestCase): queryset = SimulationRun.objects.exclude( midpoint__range=[F("start__time"), F("end__time")] ) - self.assertQuerysetEqual(queryset, [], ordered=False) + self.assertQuerySetEqual(queryset, [], ordered=False) for alias in queryset.query.alias_map.values(): if isinstance(alias, Join): self.assertEqual(alias.join_type, constants.LOUTER) @@ -1079,7 +1079,7 @@ class IterableLookupInnerExpressionsTests(TestCase): the test simple. """ queryset = Company.objects.filter(name__in=[F("num_chairs") + "1)) OR ((1==1"]) - self.assertQuerysetEqual(queryset, [], ordered=False) + self.assertQuerySetEqual(queryset, [], ordered=False) def test_in_lookup_allows_F_expressions_and_expressions_for_datetimes(self): start = datetime.datetime(2016, 2, 3, 15, 0, 0) @@ -1285,7 +1285,7 @@ class ExpressionsNumericTests(TestCase): We can fill a value in all objects with an other value of the same object. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Number.objects.all(), [(-1, -1), (42, 42), (1337, 1337)], lambda n: (n.integer, round(n.float)), @@ -1299,7 +1299,7 @@ class ExpressionsNumericTests(TestCase): self.assertEqual( Number.objects.filter(integer__gt=0).update(integer=F("integer") + 1), 2 ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Number.objects.all(), [(-1, -1), (43, 42), (1338, 1337)], lambda n: (n.integer, round(n.float)), @@ -1314,7 +1314,7 @@ class ExpressionsNumericTests(TestCase): self.assertEqual( Number.objects.filter(integer__gt=0).update(integer=F("integer") + 1), 2 ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Number.objects.exclude(float=F("integer")), [(43, 42), (1338, 1337)], lambda n: (n.integer, round(n.float)), @@ -2025,7 +2025,7 @@ class FTimeDeltaTests(TestCase): ) .order_by("name") ) - self.assertQuerysetEqual(over_estimate, ["e3", "e4", "e5"], lambda e: e.name) + self.assertQuerySetEqual(over_estimate, ["e3", "e4", "e5"], lambda e: e.name) def test_duration_with_datetime_microseconds(self): delta = datetime.timedelta(microseconds=8999999999999999) @@ -2042,7 +2042,7 @@ class FTimeDeltaTests(TestCase): more_than_4_days = Experiment.objects.filter( assigned__lt=F("completed") - Value(datetime.timedelta(days=4)) ) - self.assertQuerysetEqual(more_than_4_days, ["e3", "e4", "e5"], lambda e: e.name) + self.assertQuerySetEqual(more_than_4_days, ["e3", "e4", "e5"], lambda e: e.name) def test_negative_timedelta_update(self): # subtract 30 seconds, 30 minutes, 2 hours and 2 days diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index 221806c933..8704a7b991 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -80,7 +80,7 @@ class CaseExpressionTests(TestCase): ] def test_annotate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer=1, then=Value("one")), @@ -101,7 +101,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_without_default(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer=1, then=1), @@ -113,7 +113,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_expression_as_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_test=Case( When(integer=1, then=F("integer") + 1), @@ -126,7 +126,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_expression_as_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_test=Case( When(integer2=F("integer"), then=Value("equal")), @@ -146,7 +146,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_join_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( join_test=Case( When(integer=1, then=F("o2o_rel__integer") + 1), @@ -160,7 +160,7 @@ class CaseExpressionTests(TestCase): def test_annotate_with_in_clause(self): fk_rels = FKCaseTestModel.objects.filter(integer__in=[5]) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.only("pk", "integer") .annotate( in_test=Sum( @@ -176,7 +176,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_join_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( join_test=Case( When(integer2=F("o2o_rel__integer"), then=Value("equal")), @@ -197,7 +197,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_join_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( join_test=Case( When(o2o_rel__integer=1, then=Value("one")), @@ -219,7 +219,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_annotation_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_plus_1=F("integer") + 1, f_plus_3=F("integer") + 3, @@ -237,7 +237,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_annotation_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_plus_1=F("integer") + 1, ) @@ -261,7 +261,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_annotation_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_minus_2=F("integer") - 2, ) @@ -287,7 +287,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_aggregation_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( min=Min("fk_rel__integer"), @@ -313,7 +313,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_aggregation_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( min=Min("fk_rel__integer"), @@ -339,7 +339,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_with_aggregation_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( max=Max("fk_rel__integer"), @@ -365,7 +365,7 @@ class CaseExpressionTests(TestCase): ) def test_annotate_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer=1, then=Value("one")), @@ -426,7 +426,7 @@ class CaseExpressionTests(TestCase): self.assertTrue(all(obj.selected == "selected" for obj in objects)) def test_combined_expression(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer=1, then=2), @@ -440,7 +440,7 @@ class CaseExpressionTests(TestCase): ) def test_in_subquery(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( pk__in=CaseTestModel.objects.annotate( test=Case( @@ -469,7 +469,7 @@ class CaseExpressionTests(TestCase): When(pk=0, then=Value("0")), default=Value("1"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate(somecase=SOME_CASE).order_by("pk"), CaseTestModel.objects.annotate(somecase=SOME_CASE) .order_by("pk") @@ -532,7 +532,7 @@ class CaseExpressionTests(TestCase): ) def test_filter(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer2=Case( When(integer=2, then=3), @@ -545,7 +545,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_without_default(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer2=Case( When(integer=2, then=3), @@ -557,7 +557,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_expression_as_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer2=Case( When(integer=2, then=F("integer") + 1), @@ -570,7 +570,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_expression_as_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( string=Case( When(integer2=F("integer"), then=Value("2")), @@ -582,7 +582,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_join_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer2=Case( When(integer=2, then=F("o2o_rel__integer") + 1), @@ -595,7 +595,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_join_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer=Case( When(integer2=F("o2o_rel__integer") + 1, then=2), @@ -607,7 +607,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_join_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter( integer2=Case( When(o2o_rel__integer=1, then=1), @@ -620,7 +620,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_annotation_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f=F("integer"), f_plus_1=F("integer") + 1, @@ -637,7 +637,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_annotation_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_plus_1=F("integer") + 1, ) @@ -653,7 +653,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_annotation_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( f_plus_1=F("integer") + 1, ) @@ -670,7 +670,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_aggregation_in_value(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( min=Min("fk_rel__integer"), @@ -688,7 +688,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_aggregation_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( min=Min("fk_rel__integer"), @@ -706,7 +706,7 @@ class CaseExpressionTests(TestCase): ) def test_filter_with_aggregation_in_predicate(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values(*self.group_by_fields) .annotate( max=Max("fk_rel__integer"), @@ -730,7 +730,7 @@ class CaseExpressionTests(TestCase): default=Value("other"), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, "one"), @@ -751,7 +751,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "integer2"), @@ -765,7 +765,7 @@ class CaseExpressionTests(TestCase): default="integer", ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [("1", 2), ("2", 5), ("3", 3), ("2", 5), ("3", 3), ("3", 3), ("4", 4)], transform=attrgetter("string", "integer"), @@ -778,7 +778,7 @@ class CaseExpressionTests(TestCase): When(integer2=F("integer") + 1, then=Value("+1")), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, "equal"), @@ -823,7 +823,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "big_integer"), @@ -837,7 +837,7 @@ class CaseExpressionTests(TestCase): default=b"", ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, b"one"), @@ -859,7 +859,7 @@ class CaseExpressionTests(TestCase): default=False, ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, True), @@ -880,7 +880,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=date(2015, 1, 2)), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, date(2015, 1, 1)), @@ -901,7 +901,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=datetime(2015, 1, 2)), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, datetime(2015, 1, 1)), @@ -924,7 +924,7 @@ class CaseExpressionTests(TestCase): ), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, Decimal("1.1")), @@ -945,7 +945,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=timedelta(2)), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, timedelta(1)), @@ -967,7 +967,7 @@ class CaseExpressionTests(TestCase): default=Value(""), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, "1@example.com"), @@ -988,7 +988,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=Value("~/2")), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, "~/1"), (2, "~/2"), (3, ""), (2, "~/2"), (3, ""), (3, ""), (4, "")], transform=lambda o: (o.integer, str(o.file)), @@ -1002,7 +1002,7 @@ class CaseExpressionTests(TestCase): default=Value(""), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, "~/1"), (2, "~/2"), (3, ""), (2, "~/2"), (3, ""), (3, ""), (4, "")], transform=attrgetter("integer", "file_path"), @@ -1015,7 +1015,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2.2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1.1), (2, 2.2), (3, None), (2, 2.2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "float"), @@ -1029,7 +1029,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=Value("~/2")), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, "~/1"), (2, "~/2"), (3, ""), (2, "~/2"), (3, ""), (3, ""), (4, "")], transform=lambda o: (o.integer, str(o.image)), @@ -1043,7 +1043,7 @@ class CaseExpressionTests(TestCase): output_field=GenericIPAddressField(), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, "1.1.1.1"), @@ -1064,7 +1064,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=False), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, True), @@ -1085,7 +1085,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "positive_big_integer"), @@ -1098,7 +1098,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "positive_integer"), @@ -1111,7 +1111,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "positive_small_integer"), @@ -1125,7 +1125,7 @@ class CaseExpressionTests(TestCase): default=Value(""), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, "1"), (2, "2"), (3, ""), (2, "2"), (3, ""), (3, ""), (4, "")], transform=attrgetter("integer", "slug"), @@ -1138,7 +1138,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=2), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter("integer", "small_integer"), @@ -1151,7 +1151,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=Value("2")), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(string__in=["1", "2"]).order_by("pk"), [(1, "1"), (2, "2"), (2, "2")], transform=attrgetter("integer", "string"), @@ -1165,7 +1165,7 @@ class CaseExpressionTests(TestCase): default=Value(""), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [(1, "1"), (2, "2"), (3, ""), (2, "2"), (3, ""), (3, ""), (4, "")], transform=attrgetter("integer", "text"), @@ -1178,7 +1178,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=time(2)), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, time(1)), @@ -1200,7 +1200,7 @@ class CaseExpressionTests(TestCase): default=Value(""), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, "http://1.example.com/"), @@ -1221,7 +1221,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=UUID("22222222222222222222222222222222")), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, UUID("11111111111111111111111111111111")), @@ -1244,7 +1244,7 @@ class CaseExpressionTests(TestCase): When(integer=2, then=obj2.pk), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.order_by("pk"), [ (1, obj1.pk), @@ -1259,7 +1259,7 @@ class CaseExpressionTests(TestCase): ) def test_lookup_in_condition(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer__lt=2, then=Value("less than 2")), @@ -1280,7 +1280,7 @@ class CaseExpressionTests(TestCase): ) def test_lookup_different_fields(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(integer=2, integer2=3, then=Value("when")), @@ -1300,7 +1300,7 @@ class CaseExpressionTests(TestCase): ) def test_combined_q_object(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.annotate( test=Case( When(Q(integer=2) | Q(integer2=3), then=Value("when")), @@ -1320,7 +1320,7 @@ class CaseExpressionTests(TestCase): ) def test_order_by_conditional_implicit(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(integer__lte=2) .annotate( test=Case( @@ -1335,7 +1335,7 @@ class CaseExpressionTests(TestCase): ) def test_order_by_conditional_explicit(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(integer__lte=2) .annotate( test=Case( @@ -1357,7 +1357,7 @@ class CaseExpressionTests(TestCase): # would remove o from the results. So, in effect we are testing that # we are promoting the fk_rel join to a left outer join here. # 2. The default value of 3 is generated for the case expression. - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(pk=o.pk).annotate( foo=Case( When(fk_rel__pk=1, then=2), @@ -1368,7 +1368,7 @@ class CaseExpressionTests(TestCase): lambda x: (x, x.foo), ) # Now 2 should be generated, as the fk_rel is null. - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(pk=o.pk).annotate( foo=Case( When(fk_rel__isnull=True, then=2), @@ -1387,7 +1387,7 @@ class CaseExpressionTests(TestCase): # would remove o from the results. So, in effect we are testing that # we are promoting the fk_rel join to a left outer join here. # 2. The default value of 3 is generated for the case expression. - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(pk=o.pk).annotate( foo=Case( When(fk_rel__pk=1, then=2), @@ -1402,7 +1402,7 @@ class CaseExpressionTests(TestCase): lambda x: (x, x.foo, x.bar), ) # Now 2 should be generated, as the fk_rel is null. - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.filter(pk=o.pk).annotate( foo=Case( When(fk_rel__isnull=True, then=2), @@ -1434,7 +1434,7 @@ class CaseExpressionTests(TestCase): # The integer=4 case has one integer, thus the result is 1, and # integer=10 doesn't have any and this too generates 1 (instead of 0) # as ~Q() also matches nulls. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [(1, 2), (2, 2), (2, 2), (3, 2), (3, 2), (3, 2), (4, 1), (10, 1)], lambda x: x[1:], @@ -1459,7 +1459,7 @@ class CaseExpressionTests(TestCase): .order_by("integer") ) self.assertEqual(str(qs.query).count(" JOIN "), 1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (1, 2, 2), @@ -1485,7 +1485,7 @@ class CaseExpressionTests(TestCase): ] for case, value in tests: with self.subTest(case=case): - self.assertQuerysetEqual( + self.assertQuerySetEqual( CaseTestModel.objects.values("string") .annotate( case=case, @@ -1522,7 +1522,7 @@ class CaseDocumentationExamples(TestCase): ) def test_simple_example(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Client.objects.annotate( discount=Case( When(account_type=Client.GOLD, then=Value("5%")), @@ -1537,7 +1537,7 @@ class CaseDocumentationExamples(TestCase): def test_lookup_example(self): a_month_ago = date.today() - timedelta(days=30) a_year_ago = date.today() - timedelta(days=365) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Client.objects.annotate( discount=Case( When(registered_on__lte=a_year_ago, then=Value("10%")), @@ -1559,7 +1559,7 @@ class CaseDocumentationExamples(TestCase): default=Value(Client.REGULAR), ), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Client.objects.order_by("pk"), [("Jane Doe", "G"), ("James Smith", "R"), ("Jack Black", "P")], transform=attrgetter("name", "account_type"), @@ -1614,7 +1614,7 @@ class CaseDocumentationExamples(TestCase): def test_filter_example(self): a_month_ago = date.today() - timedelta(days=30) a_year_ago = date.today() - timedelta(days=365) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Client.objects.filter( registered_on__lte=Case( When(account_type=Client.GOLD, then=a_month_ago), diff --git a/tests/expressions_window/tests.py b/tests/expressions_window/tests.py index f3413102d5..cac6114904 100644 --- a/tests/expressions_window/tests.py +++ b/tests/expressions_window/tests.py @@ -103,7 +103,7 @@ class WindowFunctionTests(TestCase): qs = Employee.objects.annotate( rank=Window(expression=DenseRank(), order_by=order_by), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 1), @@ -137,7 +137,7 @@ class WindowFunctionTests(TestCase): order_by=[F("hire_date").asc()], ) ).order_by("department", "department_sum") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", 45000, 45000), @@ -173,7 +173,7 @@ class WindowFunctionTests(TestCase): order_by=F("hire_date__year").asc(), ) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 1), @@ -212,7 +212,7 @@ class WindowFunctionTests(TestCase): order_by=F("pk").asc(), ) ).order_by("pk") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", 1), @@ -242,7 +242,7 @@ class WindowFunctionTests(TestCase): expression=RowNumber(), ) ).order_by("pk") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", 1), @@ -269,7 +269,7 @@ class WindowFunctionTests(TestCase): partition_by="department", ) ).order_by("department", "-salary", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Adams", 50000, "Accounting", 44250.00), @@ -306,7 +306,7 @@ class WindowFunctionTests(TestCase): order_by=[F("salary").asc(), F("name").asc()], ) ).order_by("department", F("salary").asc(), F("name").asc()) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Williams", 37000, "Accounting", None), @@ -333,7 +333,7 @@ class WindowFunctionTests(TestCase): order_by=[F("bonus").asc(), F("name").asc()], ) ).order_by("department", F("bonus").asc(), F("name").asc()) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Williams", 92.5, "Accounting", None), @@ -360,7 +360,7 @@ class WindowFunctionTests(TestCase): order_by=F("hire_date").asc(), ) ).order_by("department", "hire_date") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 45000), @@ -393,7 +393,7 @@ class WindowFunctionTests(TestCase): order_by=F("hire_date").asc(), ) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ( @@ -531,7 +531,7 @@ class WindowFunctionTests(TestCase): order_by=[F("salary").asc(), F("name").asc()], ) ).order_by("department", "salary", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Williams", "Accounting", 37000, 37000), @@ -562,7 +562,7 @@ class WindowFunctionTests(TestCase): partition_by=ExtractYear("hire_date"), ) ).order_by(ExtractYear("hire_date"), "salary") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", 45000, 2005, 100000), @@ -599,7 +599,7 @@ class WindowFunctionTests(TestCase): ) ).order_by("salary", "name") # Round result of cume_dist because Oracle uses greater precision. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Moore", "IT", 34000, 0.0833333333), @@ -631,7 +631,7 @@ class WindowFunctionTests(TestCase): partition_by=F("department"), ) ).order_by("department", "hire_date", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", datetime.date(2005, 11, 1), 45000, None), @@ -670,7 +670,7 @@ class WindowFunctionTests(TestCase): partition_by="department", ) ).order_by("department", F("hire_date").asc(), F("name").desc()) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 45000), @@ -707,7 +707,7 @@ class WindowFunctionTests(TestCase): order_by=F("hire_date").asc(), ) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 37000), @@ -758,7 +758,7 @@ class WindowFunctionTests(TestCase): order_by="-salary", ) ).order_by("ntile", "-salary", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Miller", "Management", 100000, 1), @@ -789,7 +789,7 @@ class WindowFunctionTests(TestCase): ) ).order_by("percent_rank") # Round to account for precision differences among databases. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Moore", "IT", 34000, 0.0), @@ -838,7 +838,7 @@ class WindowFunctionTests(TestCase): partition_by=[F("department"), F("hire_date__year")], ) ).order_by("department", "hire_date", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 45000), @@ -876,7 +876,7 @@ class WindowFunctionTests(TestCase): order_by=[F("hire_date").asc(), F("name").asc()], ) ).order_by("department", "sum") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", 45000, "Accounting", datetime.date(2005, 11, 1), 45000), @@ -921,25 +921,25 @@ class WindowFunctionTests(TestCase): ), ).order_by("department", "name") # Direct window reference. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.filter(department_salary_rank=1), ["Adams", "Wilkinson", "Miller", "Johnson", "Smith"], lambda employee: employee.name, ) # Through a combined expression containing a window. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.filter(department_avg_age_diff__gt=0), ["Jenson", "Jones", "Williams", "Miller", "Smith"], lambda employee: employee.name, ) # Intersection of multiple windows. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.filter(department_salary_rank=1, department_avg_age_diff__gt=0), ["Miller"], lambda employee: employee.name, ) # Union of multiple windows. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.filter(Q(department_salary_rank=1) | Q(department_avg_age_diff__gt=0)), [ "Adams", @@ -1021,7 +1021,7 @@ class WindowFunctionTests(TestCase): Window(Avg("age"), partition_by="department") - F("age") ), ).order_by("department", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.filter(department_avg_age_diff__gt=0), ["Jenson", "Jones", "Williams", "Miller", "Smith"], lambda employee: employee.name, @@ -1038,7 +1038,7 @@ class WindowFunctionTests(TestCase): .filter(department_avg_age_diff__gt=0) .order_by("department", "name") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, ["Jenson", "Jones", "Williams", "Miller", "Smith"], lambda employee: employee.name, @@ -1056,19 +1056,19 @@ class WindowFunctionTests(TestCase): ), ).order_by("department", "name") # Direct window reference. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.exclude(department_salary_rank__gt=1), ["Adams", "Wilkinson", "Miller", "Johnson", "Smith"], lambda employee: employee.name, ) # Through a combined expression containing a window. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.exclude(department_avg_age_diff__lte=0), ["Jenson", "Jones", "Williams", "Miller", "Smith"], lambda employee: employee.name, ) # Union of multiple windows. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.exclude( Q(department_salary_rank__gt=1) | Q(department_avg_age_diff__lte=0) ), @@ -1076,7 +1076,7 @@ class WindowFunctionTests(TestCase): lambda employee: employee.name, ) # Intersection of multiple windows. - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs.exclude(department_salary_rank__gt=1, department_avg_age_diff__lte=0), [ "Adams", @@ -1144,7 +1144,7 @@ class WindowFunctionTests(TestCase): A query filtering against a window function have its limit applied after window filtering takes place. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Employee.objects.annotate( department_salary_rank=Window( Rank(), partition_by="department", order_by="-salary" @@ -1179,7 +1179,7 @@ class WindowFunctionTests(TestCase): ) ) self.assertIn("RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING", str(qs.query)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Williams", 37000, "Accounting", datetime.date(2009, 6, 1), 37000), @@ -1218,7 +1218,7 @@ class WindowFunctionTests(TestCase): self.assertIn( "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING", str(qs.query) ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Jones", "Accounting", 45000, datetime.date(2005, 11, 1), 165000), @@ -1260,7 +1260,7 @@ class WindowFunctionTests(TestCase): .values("hire_date")[:1], ), ).order_by("department", "name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Adams", "Accounting", datetime.date(2005, 11, 1)), @@ -1297,7 +1297,7 @@ class WindowFunctionTests(TestCase): ) ).order_by("sum", "hire_date") self.assertIn("ROWS BETWEEN UNBOUNDED PRECEDING AND 3 FOLLOWING", str(qs.query)) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Miller", 100000, "Management", datetime.date(2005, 6, 1), 280000), @@ -1430,7 +1430,7 @@ class WindowFunctionTests(TestCase): order_by=[order_by], ) ).order_by("value__department", "department_sum") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Brown", "HR", 50000, 50000), diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py index 0287eeb193..f495b2eccf 100644 --- a/tests/extra_regress/tests.py +++ b/tests/extra_regress/tests.py @@ -44,7 +44,7 @@ class ExtraRegressTests(TestCase): ] ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [("Second Revision", "First Revision")], transform=lambda r: (r.title, r.base.title), @@ -52,7 +52,7 @@ class ExtraRegressTests(TestCase): # Queryset to search for string in title: qs2 = RevisionableModel.objects.filter(title__contains="Revision") - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs2, [ ("First Revision", "First Revision"), @@ -63,7 +63,7 @@ class ExtraRegressTests(TestCase): ) # Following queryset should return the most recent revision: - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs & qs2, [("Second Revision", "First Revision")], transform=lambda r: (r.title, r.base.title), @@ -139,7 +139,7 @@ class ExtraRegressTests(TestCase): but then removes the reference because of an optimization. The table should still be present because of the extra() call. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( ( Order.objects.extra( where=["username=%s"], params=["fred"], tables=["auth_user"] diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 7d77e31b51..0fce8b092a 100644 --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -70,7 +70,7 @@ class FilteredRelationTests(TestCase): .order_by("pk", "book_join__pk") ) with self.assertNumQueries(1): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.author1, self.book1, self.editor_a, self.author1), @@ -90,7 +90,7 @@ class FilteredRelationTests(TestCase): .select_related("author_join", "editor_join") .order_by("pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.book1, self.author1, self.editor_a), @@ -120,7 +120,7 @@ class FilteredRelationTests(TestCase): .order_by("pk") ) with self.assertNumQueries(1): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.book1, self.author1), @@ -143,7 +143,7 @@ class FilteredRelationTests(TestCase): .order_by("pk") ) with self.assertNumQueries(1): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.book1, self.author1), @@ -408,7 +408,7 @@ class FilteredRelationTests(TestCase): def test_defer(self): # One query for the list and one query for the deferred title. with self.assertNumQueries(2): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Author.objects.annotate( book_alice=FilteredRelation( "book", condition=Q(book__title__iexact="poem by alice") @@ -458,7 +458,7 @@ class FilteredRelationTests(TestCase): .order_by("pk", "book_editor_worked_with__pk") ) with self.assertNumQueries(1): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.author1, self.editor_a), @@ -567,7 +567,7 @@ class FilteredRelationTests(TestCase): ) .order_by("author", "book_title", "preferred_by_author_pk") ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ ("Alice", "The book by Alice", None), @@ -594,7 +594,7 @@ class FilteredRelationTests(TestCase): .order_by("pk", "author_favorite_book_editor__pk") ) with self.assertNumQueries(1): - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ (self.book1, self.editor_b), diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index e66007d2d4..9eb2740c90 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -274,7 +274,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # Load fixture 6, JSON file with dynamic ContentType fields. Testing ManyToOne. management.call_command("loaddata", "fixture6.json", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Tag.objects.all(), [ ' tagged "copyright">', @@ -286,7 +286,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # Load fixture 7, XML file with dynamic ContentType fields. Testing ManyToOne. management.call_command("loaddata", "fixture7.xml", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Tag.objects.all(), [ ' tagged "copyright">', @@ -300,7 +300,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase): # Load fixture 8, JSON file with dynamic Permission fields. Testing ManyToMany. management.call_command("loaddata", "fixture8.json", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Visa.objects.all(), [ " tagged "copyright">', diff --git a/tests/fixtures_model_package/tests.py b/tests/fixtures_model_package/tests.py index 490bef8c03..f6c3675804 100644 --- a/tests/fixtures_model_package/tests.py +++ b/tests/fixtures_model_package/tests.py @@ -10,7 +10,7 @@ class SampleTestCase(TestCase): def test_class_fixtures(self): "Test cases can load fixture objects into models defined in packages" - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.all(), [ "Django conquers world!", @@ -26,7 +26,7 @@ class FixtureTestCase(TestCase): "Fixtures can load data into models defined in packages" # Load fixture 1. Single JSON file, with two objects management.call_command("loaddata", "model_package_fixture1.json", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.all(), [ "Time to reform copyright", @@ -38,7 +38,7 @@ class FixtureTestCase(TestCase): # Load fixture 2. JSON file imported by default. Overwrites some # existing objects management.call_command("loaddata", "model_package_fixture2.json", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.all(), [ "Django conquers world!", @@ -54,7 +54,7 @@ class FixtureTestCase(TestCase): ): management.call_command("loaddata", "unknown.json", verbosity=0) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.all(), [ "Django conquers world!", diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py index ff796feb94..2afea99b46 100644 --- a/tests/fixtures_regress/tests.py +++ b/tests/fixtures_regress/tests.py @@ -599,7 +599,7 @@ class TestFixtures(TestCase): @override_settings(FIXTURE_DIRS=[Path(_cur_dir) / "fixtures_1"]) def test_fixtures_dir_pathlib(self): management.call_command("loaddata", "inner/absolute.json", verbosity=0) - self.assertQuerysetEqual(Absolute.objects.all(), [1], transform=lambda o: o.pk) + self.assertQuerySetEqual(Absolute.objects.all(), [1], transform=lambda o: o.pk) class NaturalKeyFixtureTests(TestCase): @@ -792,7 +792,7 @@ class NaturalKeyFixtureTests(TestCase): verbosity=0, ) books = Book.objects.all() - self.assertQuerysetEqual( + self.assertQuerySetEqual( books, [ ""), @@ -35,7 +35,7 @@ class NullFkTests(TestCase): Comment.objects.select_related("post").filter(post__isnull=True)[0].post ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Comment.objects.select_related("post__forum__system_info__system_details"), [ (c1.id, "My first comment", ""), diff --git a/tests/or_lookups/tests.py b/tests/or_lookups/tests.py index 1a7264015c..bfcb32bea7 100644 --- a/tests/or_lookups/tests.py +++ b/tests/or_lookups/tests.py @@ -21,7 +21,7 @@ class OrLookupsTests(TestCase): ).pk def test_filter_or(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( ( Article.objects.filter(headline__startswith="Hello") | Article.objects.filter(headline__startswith="Goodbye") @@ -30,21 +30,21 @@ class OrLookupsTests(TestCase): attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(headline__contains="Hello") | Article.objects.filter(headline__contains="bye"), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(headline__iexact="Hello") | Article.objects.filter(headline__contains="ood"), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter( Q(headline__startswith="Hello") | Q(headline__startswith="Goodbye") ), @@ -56,12 +56,12 @@ class OrLookupsTests(TestCase): # You can shorten this syntax with code like the following, which is # especially useful if building the query in stages: articles = Article.objects.all() - self.assertQuerysetEqual( + self.assertQuerySetEqual( articles.filter(headline__startswith="Hello") & articles.filter(headline__startswith="Goodbye"), [], ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( articles.filter(headline__startswith="Hello") & articles.filter(headline__contains="bye"), ["Hello and goodbye"], @@ -69,32 +69,32 @@ class OrLookupsTests(TestCase): ) def test_pk_q(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(Q(pk=self.a1) | Q(pk=self.a2)), ["Hello", "Goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(Q(pk=self.a1) | Q(pk=self.a2) | Q(pk=self.a3)), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), ) def test_pk_in(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(pk__in=[self.a1, self.a2, self.a3]), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(pk__in=(self.a1, self.a2, self.a3)), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(pk__in=[self.a1, self.a2, self.a3, 40000]), ["Hello", "Goodbye", "Hello and goodbye"], attrgetter("headline"), @@ -108,20 +108,20 @@ class OrLookupsTests(TestCase): def test_q_negated(self): # Q objects can be negated - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(Q(pk=self.a1) | ~Q(pk=self.a2)), ["Hello", "Hello and goodbye"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(~Q(pk=self.a1) & ~Q(pk=self.a2)), ["Hello and goodbye"], attrgetter("headline"), ) # This allows for more complex queries than filter() and exclude() # alone would allow - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(Q(pk=self.a1) & (~Q(pk=self.a2) | Q(pk=self.a3))), ["Hello"], attrgetter("headline"), @@ -131,13 +131,13 @@ class OrLookupsTests(TestCase): # The 'complex_filter' method supports framework features such as # 'limit_choices_to' which normally take a single dictionary of lookup # arguments but need to support arbitrary queries via Q objects too. - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.complex_filter({"pk": self.a1}), ["Hello"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.complex_filter(Q(pk=self.a1) | Q(pk=self.a2)), ["Hello", "Goodbye"], attrgetter("headline"), @@ -145,9 +145,9 @@ class OrLookupsTests(TestCase): def test_empty_in(self): # Passing "in" an empty list returns no results ... - self.assertQuerysetEqual(Article.objects.filter(pk__in=[]), []) + self.assertQuerySetEqual(Article.objects.filter(pk__in=[]), []) # ... but can return results if we OR it with another query. - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(Q(pk__in=[]) | Q(headline__icontains="goodbye")), ["Goodbye", "Hello and goodbye"], attrgetter("headline"), @@ -155,7 +155,7 @@ class OrLookupsTests(TestCase): def test_q_and(self): # Q arg objects are ANDed - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter( Q(headline__startswith="Hello"), Q(headline__contains="bye") ), @@ -163,7 +163,7 @@ class OrLookupsTests(TestCase): attrgetter("headline"), ) # Q arg AND order is irrelevant - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter( Q(headline__contains="bye"), headline__startswith="Hello" ), @@ -171,7 +171,7 @@ class OrLookupsTests(TestCase): attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter( Q(headline__startswith="Hello") & Q(headline__startswith="Goodbye") ), @@ -179,7 +179,7 @@ class OrLookupsTests(TestCase): ) def test_q_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.exclude(Q(headline__startswith="Hello")), ["Goodbye"], attrgetter("headline"), diff --git a/tests/order_with_respect_to/base_tests.py b/tests/order_with_respect_to/base_tests.py index c895074e42..ea548ca076 100644 --- a/tests/order_with_respect_to/base_tests.py +++ b/tests/order_with_respect_to/base_tests.py @@ -25,7 +25,7 @@ class BaseOrderWithRespectToTests: def test_default_to_insertion_order(self): # Answers will always be ordered in the order they were inserted. - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.q1.answer_set.all(), [ "John", @@ -82,7 +82,7 @@ class BaseOrderWithRespectToTests: # Change the ordering to the swapped version - # this changes the ordering of the queryset. a.question.set_answer_order(id_list) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.q1.answer_set.all(), ["John", "Paul", "George", "Number five", "Ringo"], attrgetter("text"), diff --git a/tests/order_with_respect_to/tests.py b/tests/order_with_respect_to/tests.py index 1a85693eac..3682839444 100644 --- a/tests/order_with_respect_to/tests.py +++ b/tests/order_with_respect_to/tests.py @@ -44,6 +44,6 @@ class TestOrderWithRespectToOneToOnePK(TestCase): c1 = d.component_set.create() c2 = d.component_set.create() d.set_component_order([c1.id, c2.id]) - self.assertQuerysetEqual( + self.assertQuerySetEqual( d.component_set.all(), [c1.id, c2.id], attrgetter("pk") ) diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py index 8109ea1b45..88eeccf358 100644 --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -52,7 +52,7 @@ class OrderingTests(TestCase): By default, Article.objects.all() orders by pub_date descending, then headline ascending. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.all(), [ "Article 4", @@ -71,7 +71,7 @@ class OrderingTests(TestCase): Override ordering with order_by, which is in the same format as the ordering attribute in models. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("headline"), [ "Article 1", @@ -81,7 +81,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("pub_date", "-headline"), [ "Article 1", @@ -109,7 +109,7 @@ class OrderingTests(TestCase): Only the last order_by has any effect (since they each override any previous ordering). """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("id"), [ "Article 1", @@ -119,7 +119,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("id").order_by("-headline"), [ "Article 4", @@ -137,7 +137,7 @@ class OrderingTests(TestCase): F("author").desc(nulls_last=True, nulls_first=True) ) - def assertQuerysetEqualReversible(self, queryset, sequence): + def assertQuerySetEqualReversible(self, queryset, sequence): self.assertSequenceEqual(queryset, sequence) self.assertSequenceEqual(queryset.reverse(), list(reversed(sequence))) @@ -145,21 +145,21 @@ class OrderingTests(TestCase): Article.objects.filter(headline="Article 3").update(author=self.author_1) Article.objects.filter(headline="Article 4").update(author=self.author_2) # asc and desc are chainable with nulls_last. - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by(F("author").desc(nulls_last=True), "headline"), [self.a4, self.a3, self.a1, self.a2], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by(F("author").asc(nulls_last=True), "headline"), [self.a3, self.a4, self.a1, self.a2], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by( Upper("author__name").desc(nulls_last=True), "headline" ), [self.a4, self.a3, self.a1, self.a2], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by( Upper("author__name").asc(nulls_last=True), "headline" ), @@ -170,21 +170,21 @@ class OrderingTests(TestCase): Article.objects.filter(headline="Article 3").update(author=self.author_1) Article.objects.filter(headline="Article 4").update(author=self.author_2) # asc and desc are chainable with nulls_first. - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by(F("author").asc(nulls_first=True), "headline"), [self.a1, self.a2, self.a3, self.a4], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by(F("author").desc(nulls_first=True), "headline"), [self.a1, self.a2, self.a4, self.a3], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by( Upper("author__name").asc(nulls_first=True), "headline" ), [self.a1, self.a2, self.a3, self.a4], ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Article.objects.order_by( Upper("author__name").desc(nulls_first=True), "headline" ), @@ -209,7 +209,7 @@ class OrderingTests(TestCase): ) .values("last_date") ) - self.assertQuerysetEqualReversible( + self.assertQuerySetEqualReversible( Author.objects.annotate( last_date=Subquery(article_subquery, output_field=DateTimeField()) ) @@ -222,7 +222,7 @@ class OrderingTests(TestCase): """ Use the 'stop' part of slicing notation to limit the results. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("headline")[:2], [ "Article 1", @@ -236,7 +236,7 @@ class OrderingTests(TestCase): Use the 'stop' and 'start' parts of slicing notation to offset the result list. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("headline")[1:3], [ "Article 2", @@ -257,7 +257,7 @@ class OrderingTests(TestCase): This allows you to extract things like "the last two items" (reverse and then take the first two). """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.reverse()[:2], [ "Article 1", @@ -269,7 +269,7 @@ class OrderingTests(TestCase): def test_reverse_ordering_pure(self): qs1 = Article.objects.order_by(F("headline").asc()) qs2 = qs1.reverse() - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs2, [ "Article 4", @@ -279,7 +279,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs1, [ "Article 1", @@ -303,12 +303,12 @@ class OrderingTests(TestCase): author=self.author_2, second_author=self.author_1, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(headline="Article 5").reverse(), ["Name 2", "Name 1"], attrgetter("author.name"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(headline="Article 5"), ["Name 1", "Name 2"], attrgetter("author.name"), @@ -326,7 +326,7 @@ class OrderingTests(TestCase): """ Ordering can be based on fields included from an 'extra' clause """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.extra( select={"foo": "pub_date"}, order_by=["foo", "headline"] ), @@ -344,7 +344,7 @@ class OrderingTests(TestCase): If the extra clause uses an SQL keyword for a name, it will be protected by quoting. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.extra( select={"order": "pub_date"}, order_by=["order", "headline"] ), @@ -358,7 +358,7 @@ class OrderingTests(TestCase): ) def test_extra_ordering_with_table_name(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.extra(order_by=["ordering_article.headline"]), [ "Article 1", @@ -368,7 +368,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.extra(order_by=["-ordering_article.headline"]), [ "Article 4", @@ -400,7 +400,7 @@ class OrderingTests(TestCase): article.author = author article.save(update_fields={"author"}) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by("author_id"), [ "Article 4", @@ -416,19 +416,19 @@ class OrderingTests(TestCase): self.a1.save() self.a2.author = Author.objects.create(editor=self.author_2) self.a2.save() - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(author__isnull=False).order_by("author__editor"), ["Article 2", "Article 1"], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.filter(author__isnull=False).order_by("author__editor_id"), ["Article 1", "Article 2"], attrgetter("headline"), ) def test_order_by_f_expression(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by(F("headline")), [ "Article 1", @@ -438,7 +438,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by(F("headline").asc()), [ "Article 1", @@ -448,7 +448,7 @@ class OrderingTests(TestCase): ], attrgetter("headline"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Article.objects.order_by(F("headline").desc()), [ "Article 4", @@ -468,7 +468,7 @@ class OrderingTests(TestCase): sql = str(qs.query).upper() fragment = sql[sql.find("ORDER BY") :] self.assertEqual(fragment.count("HEADLINE"), 1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "Article 1", @@ -482,7 +482,7 @@ class OrderingTests(TestCase): sql = str(qs.query).upper() fragment = sql[sql.find("ORDER BY") :] self.assertEqual(fragment.count("HEADLINE"), 1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs, [ "Article 4", @@ -535,7 +535,7 @@ class OrderingTests(TestCase): articles = OrderedByFArticle.objects.all() articles.filter(headline="Article 2").update(author=self.author_2) articles.filter(headline="Article 3").update(author=self.author_1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( articles, ["Article 1", "Article 4", "Article 3", "Article 2"], attrgetter("headline"), diff --git a/tests/postgres_tests/test_trigram.py b/tests/postgres_tests/test_trigram.py index 2d7549fb4b..3fa0550441 100644 --- a/tests/postgres_tests/test_trigram.py +++ b/tests/postgres_tests/test_trigram.py @@ -31,7 +31,7 @@ class TrigramTest(PostgreSQLTestCase): ) def test_trigram_search(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__trigram_similar="Mathew"), ["Matthew"], transform=lambda instance: instance.field, @@ -68,7 +68,7 @@ class TrigramTest(PostgreSQLTestCase): def test_trigram_similarity(self): search = "Bat sat on cat." # Round result of similarity because PostgreSQL uses greater precision. - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter( field__trigram_similar=search, ) @@ -111,7 +111,7 @@ class TrigramTest(PostgreSQLTestCase): def test_trigram_similarity_alternate(self): # Round result of distance because PostgreSQL uses greater precision. - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.annotate( distance=TrigramDistance("field", "Bat sat on cat."), ) diff --git a/tests/postgres_tests/test_unaccent.py b/tests/postgres_tests/test_unaccent.py index 4188d90794..a512184589 100644 --- a/tests/postgres_tests/test_unaccent.py +++ b/tests/postgres_tests/test_unaccent.py @@ -21,7 +21,7 @@ class UnaccentTest(PostgreSQLTestCase): ) def test_unaccent(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__unaccent="aeO"), ["àéÖ", "aeO"], transform=lambda instance: instance.field, @@ -33,13 +33,13 @@ class UnaccentTest(PostgreSQLTestCase): Unaccent can be used chained with a lookup (which should be the case since unaccent implements the Transform API) """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__unaccent__iexact="aeO"), ["àéÖ", "aeO", "aeo"], transform=lambda instance: instance.field, ordered=False, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__unaccent__endswith="éÖ"), ["àéÖ", "aeO"], transform=lambda instance: instance.field, @@ -54,7 +54,7 @@ class UnaccentTest(PostgreSQLTestCase): if disable_conforming_strings: cursor.execute("SET standard_conforming_strings TO off") try: - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__unaccent__endswith="éÖ"), ["àéÖ", "aeO"], transform=lambda instance: instance.field, @@ -65,7 +65,7 @@ class UnaccentTest(PostgreSQLTestCase): cursor.execute("SET standard_conforming_strings TO on") def test_unaccent_accentuated_needle(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.Model.objects.filter(field__unaccent="aéÖ"), ["àéÖ", "aeO"], transform=lambda instance: instance.field, diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index 5fc09ca922..97b3f97b68 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -15,7 +15,7 @@ class QuerySetSetOperationTests(TestCase): Number.objects.bulk_create(Number(num=i, other_num=10 - i) for i in range(10)) def assertNumbersEqual(self, queryset, expected_numbers, ordered=True): - self.assertQuerysetEqual( + self.assertQuerySetEqual( queryset, expected_numbers, operator.attrgetter("num"), ordered ) @@ -145,7 +145,7 @@ class QuerySetSetOperationTests(TestCase): def test_ordering_by_alias(self): qs1 = Number.objects.filter(num__lte=1).values(alias=F("num")) qs2 = Number.objects.filter(num__gte=2, num__lte=3).values(alias=F("num")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs1.union(qs2).order_by("-alias"), [3, 2, 1, 0], operator.itemgetter("alias"), @@ -159,13 +159,13 @@ class QuerySetSetOperationTests(TestCase): def test_ordering_by_f_expression_and_alias(self): qs1 = Number.objects.filter(num__lte=1).values(alias=F("other_num")) qs2 = Number.objects.filter(num__gte=2, num__lte=3).values(alias=F("other_num")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs1.union(qs2).order_by(F("alias").desc()), [10, 9, 8, 7], operator.itemgetter("alias"), ) Number.objects.create(num=-1) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs1.union(qs2).order_by(F("alias").desc(nulls_last=True)), [10, 9, 8, 7, None], operator.itemgetter("alias"), @@ -267,7 +267,7 @@ class QuerySetSetOperationTests(TestCase): qs1.union(qs2).order_by("annotation", "num").values_list("num", flat=True), [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( qs1.union(qs2) .order_by( F("annotation") * F("multiplier"), diff --git a/tests/queries/tests.py b/tests/queries/tests.py index f2948cd81f..63e9ea6687 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -662,7 +662,7 @@ class Queries1Tests(TestCase): def test_tickets_2874_3002(self): qs = Item.objects.select_related().order_by("note__note", "name") - self.assertQuerysetEqual(qs, [self.i2, self.i4, self.i1, self.i3]) + self.assertQuerySetEqual(qs, [self.i2, self.i4, self.i1, self.i3]) # This is also a good select_related() test because there are multiple # Note entries in the SQL. The two Note items should be different. @@ -1075,41 +1075,41 @@ class Queries1Tests(TestCase): Tag._meta.ordering = original_ordering def test_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.exclude(tags__name="t4"), Item.objects.filter(~Q(tags__name="t4")), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.exclude(Q(tags__name="t4") | Q(tags__name="t3")), Item.objects.filter(~(Q(tags__name="t4") | Q(tags__name="t3"))), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.exclude(Q(tags__name="t4") | ~Q(tags__name="t3")), Item.objects.filter(~(Q(tags__name="t4") | ~Q(tags__name="t3"))), ) def test_nested_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.exclude(~Q(tags__name="t4")), Item.objects.filter(~~Q(tags__name="t4")), ) def test_double_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.filter(Q(tags__name="t4")), Item.objects.filter(~~Q(tags__name="t4")), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.filter(Q(tags__name="t4")), Item.objects.filter(~Q(~Q(tags__name="t4"))), ) def test_exclude_in(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.exclude(Q(tags__name__in=["t4", "t3"])), Item.objects.filter(~Q(tags__name__in=["t4", "t3"])), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Item.objects.filter(Q(tags__name__in=["t4", "t3"])), Item.objects.filter(~~Q(tags__name__in=["t4", "t3"])), ) @@ -1996,7 +1996,7 @@ class SubclassFKTests(TestCase): class CustomPkTests(TestCase): def test_ticket7371(self): - self.assertQuerysetEqual(Related.objects.order_by("custom"), []) + self.assertQuerySetEqual(Related.objects.order_by("custom"), []) class NullableRelOrderingTests(TestCase): @@ -2947,8 +2947,8 @@ class WeirdQuerysetSlicingTests(TestCase): def test_zero_length_values_slicing(self): n = 42 with self.assertNumQueries(0): - self.assertQuerysetEqual(Article.objects.values()[n:n], []) - self.assertQuerysetEqual(Article.objects.values_list()[n:n], []) + self.assertQuerySetEqual(Article.objects.values()[n:n], []) + self.assertQuerySetEqual(Article.objects.values_list()[n:n], []) class EscapingTests(TestCase): @@ -3479,23 +3479,23 @@ class NullInExcludeTest(TestCase): def test_null_in_exclude_qs(self): none_val = "" if connection.features.interprets_empty_strings_as_nulls else None - self.assertQuerysetEqual( + self.assertQuerySetEqual( NullableName.objects.exclude(name__in=[]), ["i1", none_val], attrgetter("name"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( NullableName.objects.exclude(name__in=["i1"]), [none_val], attrgetter("name"), ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( NullableName.objects.exclude(name__in=["i3"]), ["i1", none_val], attrgetter("name"), ) inner_qs = NullableName.objects.filter(name="i1").values_list("name") - self.assertQuerysetEqual( + self.assertQuerySetEqual( NullableName.objects.exclude(name__in=inner_qs), [none_val], attrgetter("name"), @@ -3511,7 +3511,7 @@ class NullInExcludeTest(TestCase): SQL's COL NOT IN (list containing null) handling is too weird to abstract away. """ - self.assertQuerysetEqual( + self.assertQuerySetEqual( NullableName.objects.exclude(name__in=[None]), ["i1"], attrgetter("name") ) @@ -3537,14 +3537,14 @@ class EmptyStringsAsNullTest(TestCase): cls.nc = NamedCategory.objects.create(name="") def test_direct_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( NamedCategory.objects.exclude(name__in=["nonexistent"]), [self.nc.pk], attrgetter("pk"), ) def test_joined_exclude(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( DumbCategory.objects.exclude(namedcategory__name__in=["nonexistent"]), [self.nc.pk], attrgetter("pk"), @@ -3552,7 +3552,7 @@ class EmptyStringsAsNullTest(TestCase): def test_21001(self): foo = NamedCategory.objects.create(name="foo") - self.assertQuerysetEqual( + self.assertQuerySetEqual( NamedCategory.objects.exclude(name=""), [foo.pk], attrgetter("pk") ) @@ -3760,7 +3760,7 @@ class NullJoinPromotionOrTest(TestCase): qs1_filter = Identifier.objects.filter( program__id=p1.id, channel__id=c1.id ).order_by("pk") - self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) + self.assertQuerySetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual( str(qs1_filter.query).count("JOIN"), str(qs1_doubleneg.query).count("JOIN") ) @@ -3785,7 +3785,7 @@ class NullJoinPromotionOrTest(TestCase): qs1_doubleneg = Identifier.objects.exclude( ~Q(Q(program__id=p2.id, channel__id=c1.id) | Q(program__id=p1.id)) ).order_by("pk") - self.assertQuerysetEqual(qs1_doubleneg, qs1_filter, lambda x: x) + self.assertQuerySetEqual(qs1_doubleneg, qs1_filter, lambda x: x) self.assertEqual( str(qs1_filter.query).count("JOIN"), str(qs1_doubleneg.query).count("JOIN") ) @@ -3811,7 +3811,7 @@ class NullJoinPromotionOrTest(TestCase): qs2 = Identifier.objects.filter( Q(Q(program__id=p2.id, channel__id=c1.id) | ~Q(program__id=p1.id)) ).order_by("pk") - self.assertQuerysetEqual(qs1, qs2, lambda x: x) + self.assertQuerySetEqual(qs1, qs2, lambda x: x) self.assertEqual(str(qs1.query).count("JOIN"), str(qs2.query).count("JOIN")) self.assertEqual(0, str(qs1.query).count("INNER JOIN")) self.assertEqual( diff --git a/tests/save_delete_hooks/tests.py b/tests/save_delete_hooks/tests.py index 755fb1a008..4bd97b54c8 100644 --- a/tests/save_delete_hooks/tests.py +++ b/tests/save_delete_hooks/tests.py @@ -16,7 +16,7 @@ class SaveDeleteHookTests(TestCase): ], ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.all(), [ "John Smith", @@ -34,4 +34,4 @@ class SaveDeleteHookTests(TestCase): "After deletion", ], ) - self.assertQuerysetEqual(Person.objects.all(), []) + self.assertQuerySetEqual(Person.objects.all(), []) diff --git a/tests/servers/tests.py b/tests/servers/tests.py index 480bc827c1..91f766926b 100644 --- a/tests/servers/tests.py +++ b/tests/servers/tests.py @@ -328,7 +328,7 @@ class LiveServerDatabase(LiveServerBase): """ with self.urlopen("/create_model_instance/"): pass - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("pk"), ["jane", "robert", "emily"], lambda b: b.name, diff --git a/tests/signals/tests.py b/tests/signals/tests.py index 4636e97330..0385033b07 100644 --- a/tests/signals/tests.py +++ b/tests/signals/tests.py @@ -178,7 +178,7 @@ class SignalTests(BaseSignalSetup, TestCase): ) data[:] = [] - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.all(), [ "James Jones", diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index b22aa273d5..9304f22a2e 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -264,47 +264,56 @@ class AssertNumQueriesUponConnectionTests(TransactionTestCase): list(Car.objects.all()) -class AssertQuerysetEqualTests(TestCase): +class AssertQuerySetEqualTests(TestCase): @classmethod def setUpTestData(cls): cls.p1 = Person.objects.create(name="p1") cls.p2 = Person.objects.create(name="p2") - def test_empty(self): + def test_rename_assertquerysetequal_deprecation_warning(self): + msg = "assertQuerysetEqual() is deprecated in favor of assertQuerySetEqual()." + with self.assertRaisesMessage(RemovedInDjango51Warning, msg): + self.assertQuerysetEqual() + + @ignore_warnings(category=RemovedInDjango51Warning) + def test_deprecated_assertquerysetequal(self): self.assertQuerysetEqual(Person.objects.filter(name="p3"), []) + def test_empty(self): + self.assertQuerySetEqual(Person.objects.filter(name="p3"), []) + def test_ordered(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name"), [self.p1, self.p2], ) def test_unordered(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name"), [self.p2, self.p1], ordered=False ) def test_queryset(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name"), Person.objects.order_by("name"), ) def test_flat_values_list(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name").values_list("name", flat=True), ["p1", "p2"], ) def test_transform(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name"), [self.p1.pk, self.p2.pk], transform=lambda x: x.pk, ) def test_repr_transform(self): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.order_by("name"), [repr(self.p1), repr(self.p2)], transform=repr, @@ -318,16 +327,16 @@ class AssertQuerysetEqualTests(TestCase): "ordered value." ) with self.assertRaisesMessage(ValueError, msg): - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.all(), [self.p1, self.p2], ) # No error for one value. - self.assertQuerysetEqual(Person.objects.filter(name="p1"), [self.p1]) + self.assertQuerySetEqual(Person.objects.filter(name="p1"), [self.p1]) def test_repeated_values(self): """ - assertQuerysetEqual checks the number of appearance of each item + assertQuerySetEqual checks the number of appearance of each item when used with option ordered=False. """ batmobile = Car.objects.create(name="Batmobile") @@ -343,10 +352,10 @@ class AssertQuerysetEqualTests(TestCase): ] ) with self.assertRaises(AssertionError): - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.p1.cars.all(), [batmobile, k2000], ordered=False ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( self.p1.cars.all(), [batmobile] * 2 + [k2000] * 4, ordered=False ) @@ -356,7 +365,7 @@ class AssertQuerysetEqualTests(TestCase): names.append("Extra Person") with self.assertRaises(AssertionError) as ctx: - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.filter(name__startswith="Joe"), names, ordered=False, @@ -368,7 +377,7 @@ class AssertQuerysetEqualTests(TestCase): self.maxDiff = None try: with self.assertRaises(AssertionError) as ctx: - self.assertQuerysetEqual( + self.assertQuerySetEqual( Person.objects.filter(name__startswith="Joe"), names, ordered=False, diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 7ed8c1bb12..dab481068b 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -240,19 +240,19 @@ class LegacyDatabaseTests(TestCase): ) morning_min_dt = datetime.datetime(2011, 9, 1, 3, 20, 40) afternoon_min_dt = datetime.datetime(2011, 9, 1, 13, 20, 30) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).order_by("dt"), [morning_min_dt, afternoon_min_dt], transform=lambda d: d.dt, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).filter( dt__lt=afternoon_min_dt ), [morning_min_dt], transform=lambda d: d.dt, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).filter( dt__gte=afternoon_min_dt ), @@ -536,19 +536,19 @@ class NewDatabaseTests(TestCase): ) morning_min_dt = datetime.datetime(2011, 9, 1, 3, 20, 40, tzinfo=EAT) afternoon_min_dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).order_by("dt"), [morning_min_dt, afternoon_min_dt], transform=lambda d: d.dt, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).filter( dt__lt=afternoon_min_dt ), [morning_min_dt], transform=lambda d: d.dt, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( Session.objects.annotate(dt=Min("events__dt")).filter( dt__gte=afternoon_min_dt ),