diff options
author | Tim Graham <timograham@gmail.com> | 2017-06-11 15:52:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-11 15:52:19 -0400 |
commit | 3d0a0ecd2cc5d7bfe0b53c33255c1b6564c160a4 (patch) | |
tree | bece1fab2425bbf978c27315bd018c827e0634d2 /tests/model_regress | |
parent | 3eb3907bb1b4d8e57331d4a8181b28971613b761 (diff) | |
download | django-3d0a0ecd2cc5d7bfe0b53c33255c1b6564c160a4.tar.gz |
Refs #23919 -- Removed support for broken Model.__str__() in Model.__repr__().
Returning invalid bytestrings in __str__() is unlikely in Python 3.
Diffstat (limited to 'tests/model_regress')
-rw-r--r-- | tests/model_regress/models.py | 8 | ||||
-rw-r--r-- | tests/model_regress/tests.py | 9 |
2 files changed, 2 insertions, 15 deletions
diff --git a/tests/model_regress/models.py b/tests/model_regress/models.py index 7af20e44d3..b9db796dcb 100644 --- a/tests/model_regress/models.py +++ b/tests/model_regress/models.py @@ -52,14 +52,6 @@ class Worker(models.Model): return self.name -class BrokenStrMethod(models.Model): - name = models.CharField(max_length=7) - - def __str__(self): - # Intentionally broken (invalid start byte in byte string). - return b'Name\xff: %s'.decode() % self.name - - class NonAutoPK(models.Model): name = models.CharField(max_length=10, primary_key=True) diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py index 1988a3fd09..cb0b530063 100644 --- a/tests/model_regress/tests.py +++ b/tests/model_regress/tests.py @@ -8,8 +8,8 @@ from django.test import TestCase, skipUnlessDBFeature from django.utils.timezone import get_fixed_timezone from .models import ( - Article, BrokenStrMethod, Department, Event, Model1, Model2, Model3, - NonAutoPK, Party, Worker, + Article, Department, Event, Model1, Model2, Model3, NonAutoPK, Party, + Worker, ) @@ -186,11 +186,6 @@ class ModelTests(TestCase): w = Worker.objects.create(department=d, name="Full-time") self.assertEqual(str(w), "Full-time") - def test_broken_unicode(self): - # Models with broken __str__() methods have a printable repr(). - b = BrokenStrMethod.objects.create(name='Jerry') - self.assertEqual(repr(b), '<BrokenStrMethod: [Bad Unicode data]>') - @skipUnlessDBFeature("supports_timezones") def test_timezones(self): # Saving an updating with timezone-aware datetime Python objects. |