summaryrefslogtreecommitdiff
path: root/tests/custom_methods
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/custom_methods
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
downloaddjango-9c19aff7c7561e3a82978a272ecdaad40dda5c00.tar.gz
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/custom_methods')
-rw-r--r--tests/custom_methods/models.py9
-rw-r--r--tests/custom_methods/tests.py16
2 files changed, 16 insertions, 9 deletions
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,
)