Added extra assertion to migrations.test_writer.WriterTests.test_serialize_datetime.

This checks that datetime.timezone.utc serializes correctly.
This commit is contained in:
Nick Pope 2021-05-07 13:56:57 +01:00 committed by Carlton Gibson
parent 88b3982af3
commit 6b7960188b
1 changed files with 9 additions and 7 deletions

View File

@ -492,13 +492,15 @@ class WriterTests(SimpleTestCase):
datetime.datetime(2014, 1, 1, 1, 1), datetime.datetime(2014, 1, 1, 1, 1),
("datetime.datetime(2014, 1, 1, 1, 1)", {'import datetime'}) ("datetime.datetime(2014, 1, 1, 1, 1)", {'import datetime'})
) )
self.assertSerializedResultEqual( for tzinfo in (utc, datetime.timezone.utc):
datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc), with self.subTest(tzinfo=tzinfo):
( self.assertSerializedResultEqual(
"datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc)", datetime.datetime(2012, 1, 1, 1, 1, tzinfo=tzinfo),
{'import datetime', 'from django.utils.timezone import utc'}, (
) "datetime.datetime(2012, 1, 1, 1, 1, tzinfo=utc)",
) {'import datetime', 'from django.utils.timezone import utc'},
)
)
def test_serialize_fields(self): def test_serialize_fields(self):
self.assertSerializedFieldEqual(models.CharField(max_length=255)) self.assertSerializedFieldEqual(models.CharField(max_length=255))