diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2014-09-25 20:21:12 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-09-25 17:50:50 -0400 |
| commit | e8a08514de6b97de1fce13b6c6b24cf72d1d60d9 (patch) | |
| tree | a9d43c0bd2f7262068bd59657cc7cff19913407c /tests | |
| parent | 1dec42822c76c10ca9c1dc939546758c0c11b1b7 (diff) | |
[1.7.x] Fixed #23455 -- Forced related_name to be a unicode string during deconstruction.
Backport of 45bd7b3bd9 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/field_deconstruction/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py index 1cf3bb4c2c..db1b5ae7d4 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): |
