summaryrefslogtreecommitdiff
path: root/tests/field_deconstruction
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2014-09-25 20:21:12 +0200
committerTim Graham <timograham@gmail.com>2014-09-25 17:49:44 -0400
commit45bd7b3bd9008941580c100b9fc7361e3ff3ff0d (patch)
tree2387e0e8fe6328fc31013553846dc5974a4e1e78 /tests/field_deconstruction
parentd8e157d5ab1648a509b25d5ec571572ae936de79 (diff)
Fixed #23455 -- Forced related_name to be a unicode string during deconstruction.
Diffstat (limited to 'tests/field_deconstruction')
-rw-r--r--tests/field_deconstruction/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
index 6253c8e61b..998d1ab980 100644
--- a/tests/field_deconstruction/tests.py
+++ b/tests/field_deconstruction/tests.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
import warnings
from django.db import models
@@ -209,6 +211,12 @@ class FieldDeconstructionTests(TestCase):
self.assertEqual(path, "django.db.models.ForeignKey")
self.assertEqual(args, [])
self.assertEqual(kwargs, {"to": "auth.Permission", "related_name": "foobar"})
+ # Test related_name unicode conversion
+ field = models.ForeignKey("auth.Permission", related_name=b"foobar")
+ name, path, args, kwargs = field.deconstruct()
+ self.assertEqual(path, "django.db.models.ForeignKey")
+ self.assertEqual(args, [])
+ self.assertEqual(kwargs, {"to": "auth.Permission", "related_name": "foobar"})
@override_settings(AUTH_USER_MODEL="auth.Permission")
def test_foreign_key_swapped(self):
@@ -289,6 +297,12 @@ class FieldDeconstructionTests(TestCase):
self.assertEqual(path, "django.db.models.ManyToManyField")
self.assertEqual(args, [])
self.assertEqual(kwargs, {"to": "auth.Permission", "related_name": "custom_table"})
+ # Test related_name unicode conversion
+ field = models.ManyToManyField("auth.Permission", related_name=b"custom_table")
+ name, path, args, kwargs = field.deconstruct()
+ self.assertEqual(path, "django.db.models.ManyToManyField")
+ self.assertEqual(args, [])
+ self.assertEqual(kwargs, {"to": "auth.Permission", "related_name": "custom_table"})
@override_settings(AUTH_USER_MODEL="auth.Permission")
def test_many_to_many_field_swapped(self):