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

Fixed #26281 -- Added a helpful error message for an invalid format specifier to dateformat.format().

This commit is contained in:
Marko Benko
2016-04-03 19:31:35 +02:00
committed by Tim Graham
parent b040ac06eb
commit 45c7acdc50
3 changed files with 18 additions and 2 deletions

View File

@@ -153,3 +153,14 @@ class DateFormatTests(SimpleTestCase):
# Ticket #16924 -- We don't need timezone support to test this
self.assertEqual(dateformat.format(aware_dt, 'O'), '-0330')
def test_invalid_time_format_specifiers(self):
my_birthday = date(1984, 8, 7)
for specifier in ['a', 'A', 'f', 'g', 'G', 'h', 'H', 'i', 'P', 's', 'u']:
msg = (
"The format for date objects may not contain time-related "
"format specifiers (found '%s')." % specifier
)
with self.assertRaisesMessage(TypeError, msg):
dateformat.format(my_birthday, specifier)