1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #16123 -- Ensured strptime receive proper string type

strptime generates an UnicodeEncodeError when using a non-ascii
unicode string on Python 2.
This commit is contained in:
Claude Paroz
2013-01-26 20:49:02 +01:00
parent 962f133f72
commit 4b3f7110ae
4 changed files with 18 additions and 7 deletions

View File

@@ -370,6 +370,16 @@ class FieldsTests(SimpleTestCase):
self.assertFalse(f._has_changed(d, '17/09/2007'))
self.assertFalse(f._has_changed(d.strftime(format), '17/09/2007'))
def test_datefield_strptime(self):
"""Test that field.strptime doesn't raise an UnicodeEncodeError (#16123)"""
f = DateField()
try:
f.strptime('31 мая 2011', '%d-%b-%y')
except Exception as e:
# assertIsInstance or assertRaises cannot be used because UnicodeEncodeError
# is a subclass of ValueError
self.assertEqual(e.__class__, ValueError)
# TimeField ###################################################################
def test_timefield_1(self):