summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2016-05-04 22:05:11 +0200
committerMarkus Holtermann <info@markusholtermann.eu>2016-05-04 22:39:19 +0200
commit3b383085fb89a48e756383e7cd5d3bd867353ba1 (patch)
tree9ba2e462dc6c1315f0a5a6eeec94bf0db8a89dda /tests
parent3204bc8e5e4845cf9fbd12246f83ae851081870e (diff)
Fixed #26555 -- Gave deconstructible objects a higher priority during serialization
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_writer.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 6c121e0904..8febf40f03 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
import datetime
+import decimal
import functools
import math
import os
@@ -35,6 +36,15 @@ except ImportError:
enum = None
+class Money(decimal.Decimal):
+ def deconstruct(self):
+ return (
+ '%s.%s' % (self.__class__.__module__, self.__class__.__name__),
+ [six.text_type(self)],
+ {}
+ )
+
+
class TestModel1(object):
def upload_to(self):
return "somewhere dynamic"
@@ -200,6 +210,18 @@ class WriterTests(SimpleTestCase):
self.assertTrue(math.isinf(self.serialize_round_trip(float("-inf"))))
self.assertTrue(math.isnan(self.serialize_round_trip(float("nan"))))
+ self.assertSerializedEqual(decimal.Decimal('1.3'))
+ self.assertSerializedResultEqual(
+ decimal.Decimal('1.3'),
+ ("Decimal('1.3')", {'from decimal import Decimal'})
+ )
+
+ self.assertSerializedEqual(Money('1.3'))
+ self.assertSerializedResultEqual(
+ Money('1.3'),
+ ("migrations.test_writer.Money('1.3')", {'import migrations.test_writer'})
+ )
+
def test_serialize_constants(self):
self.assertSerializedEqual(None)
self.assertSerializedEqual(True)