summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2015-11-25 12:31:23 -0500
committerSimon Charette <charette.s@gmail.com>2015-11-26 11:21:35 -0500
commitb4a1d545db19bb427af4043ce2c689dad856514f (patch)
tree3e5a60813e6ac434f2673563f2cb141a0b44fa9b /tests
parentf7e599ad25e52e8108a2bf6c17fb203b398ed986 (diff)
[1.9.x] 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. Backport of cc2ca9c550fbf8fca8684b373a3c8e3618eea08e from master
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_writer.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 12df772df5..b3c41565e3 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 _
@@ -229,6 +230,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)
+
def test_serialize_functions(self):
with six.assertRaisesRegex(self, ValueError, 'Cannot serialize function: lambda'):
self.assertSerializedEqual(lambda x: 42)