From 9c19aff7c7561e3a82978a272ecdaad40dda5c00 Mon Sep 17 00:00:00 2001 From: django-bot Date: Thu, 3 Feb 2022 20:24:19 +0100 Subject: Refs #33476 -- Reformatted code with Black. --- tests/custom_methods/models.py | 9 ++++++--- tests/custom_methods/tests.py | 16 ++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'tests/custom_methods') diff --git a/tests/custom_methods/models.py b/tests/custom_methods/models.py index f44d1b8265..1ff823297d 100644 --- a/tests/custom_methods/models.py +++ b/tests/custom_methods/models.py @@ -28,11 +28,14 @@ class Article(models.Model): database query for the sake of demonstration. """ from django.db import connection + with connection.cursor() as cursor: - cursor.execute(""" + cursor.execute( + """ SELECT id, headline, pub_date FROM custom_methods_article WHERE pub_date = %s - AND id != %s""", [connection.ops.adapt_datefield_value(self.pub_date), - self.id]) + AND id != %s""", + [connection.ops.adapt_datefield_value(self.pub_date), self.id], + ) return [self.__class__(*row) for row in cursor.fetchall()] diff --git a/tests/custom_methods/tests.py b/tests/custom_methods/tests.py index bbcec1f9f2..2bae2d2623 100644 --- a/tests/custom_methods/tests.py +++ b/tests/custom_methods/tests.py @@ -16,27 +16,31 @@ class MethodsTests(TestCase): self.assertFalse(a.was_published_today()) self.assertQuerysetEqual( - a.articles_from_same_day_1(), [ + a.articles_from_same_day_1(), + [ "Beatles reunite", ], lambda a: a.headline, ) self.assertQuerysetEqual( - a.articles_from_same_day_2(), [ + a.articles_from_same_day_2(), + [ "Beatles reunite", ], - lambda a: a.headline + lambda a: a.headline, ) self.assertQuerysetEqual( - b.articles_from_same_day_1(), [ + b.articles_from_same_day_1(), + [ "Parrot programs in Python", ], lambda a: a.headline, ) self.assertQuerysetEqual( - b.articles_from_same_day_2(), [ + b.articles_from_same_day_2(), + [ "Parrot programs in Python", ], - lambda a: a.headline + lambda a: a.headline, ) -- cgit v1.3