mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #18063 -- Avoid unicode in Model.__repr__ in python 2
Thanks guettli and mrmachine.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# coding: utf-8
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import datetime
|
||||
@@ -146,6 +148,14 @@ class ModelTests(TestCase):
|
||||
b = BrokenUnicodeMethod.objects.create(name="Jerry")
|
||||
self.assertEqual(repr(b), "<BrokenUnicodeMethod: [Bad Unicode data]>")
|
||||
|
||||
def test_no_unicode_in_repr(self):
|
||||
a = Article.objects.create(
|
||||
headline="Watch for umlauts: üöä", pub_date=datetime.datetime.now())
|
||||
if six.PY3:
|
||||
self.assertEqual(repr(a), '<Article: Watch for umlauts: üöä>')
|
||||
else:
|
||||
self.assertEqual(repr(a), '<Article: Watch for umlauts: ???>')
|
||||
|
||||
@skipUnlessDBFeature("supports_timezones")
|
||||
def test_timezones(self):
|
||||
# Saving an updating with timezone-aware datetime Python objects.
|
||||
|
||||
Reference in New Issue
Block a user