From 6b7960188b4fa0a2b357d8f40a3316e2e3755e87 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Fri, 7 May 2021 13:56:57 +0100 Subject: [PATCH] Added extra assertion to migrations.test_writer.WriterTests.test_serialize_datetime. This checks that datetime.timezone.utc serializes correctly. --- tests/migrations/test_writer.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index 5635dc62f0..96b2140089 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -492,13 +492,15 @@ class WriterTests(SimpleTestCase): datetime.datetime(2014, 1, 1, 1, 1), ("datetime.datetime(2014, 1, 1, 1, 1)", {'import datetime'}) ) - self.assertSerializedResultEqual( - datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc), - ( - "datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc)", - {'import datetime', 'from django.utils.timezone import utc'}, - ) - ) + for tzinfo in (utc, datetime.timezone.utc): + with self.subTest(tzinfo=tzinfo): + self.assertSerializedResultEqual( + datetime.datetime(2012, 1, 1, 1, 1, tzinfo=tzinfo), + ( + "datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc)", + {'import datetime', 'from django.utils.timezone import utc'}, + ) + ) def test_serialize_fields(self): self.assertSerializedFieldEqual(models.CharField(max_length=255))