From cc2ca9c550fbf8fca8684b373a3c8e3618eea08e Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Wed, 25 Nov 2015 12:31:23 -0500 Subject: Fixed #25807 -- Instructed the migration writer about lazy objects. Thanks to Trac alias mrgaolei for the report, Baptiste for the confirmation and Tim for the review. --- tests/migrations/test_writer.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index e6928b6bbb..fb08a949c8 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -23,6 +23,7 @@ from django.test import SimpleTestCase, ignore_warnings, mock from django.utils import datetime_safe, six from django.utils._os import upath from django.utils.deconstruct import deconstructible +from django.utils.functional import SimpleLazyObject from django.utils.timezone import FixedOffset, get_default_timezone, utc from django.utils.translation import ugettext_lazy as _ @@ -234,6 +235,11 @@ class WriterTests(SimpleTestCase): ("[list, tuple, dict, set, frozenset]", set()) ) + def test_serialize_lazy_objects(self): + pattern = re.compile(r'^foo$', re.UNICODE) + lazy_pattern = SimpleLazyObject(lambda: pattern) + self.assertEqual(self.serialize_round_trip(lazy_pattern), pattern) + @unittest.skipUnless(enum, "enum34 is required on Python 2") def test_serialize_enums(self): class TextEnum(enum.Enum): -- cgit v1.3