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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user