summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_dateformat.py
diff options
context:
space:
mode:
authorMarko Benko <marko.benko@gmail.com>2016-04-03 19:31:35 +0200
committerTim Graham <timograham@gmail.com>2016-04-20 20:13:52 -0400
commit45c7acdc507d26451f3c3f22b5d60bdd6d572cfc (patch)
treea53bc612d6bcebae325801aca468922914584b76 /tests/utils_tests/test_dateformat.py
parentb040ac06ebba2348cece7390b88f746d2c91d07b (diff)
Fixed #26281 -- Added a helpful error message for an invalid format specifier to dateformat.format().
Diffstat (limited to 'tests/utils_tests/test_dateformat.py')
-rw-r--r--tests/utils_tests/test_dateformat.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py
index 143fbee4e3..bda69fb4cd 100644
--- a/tests/utils_tests/test_dateformat.py
+++ b/tests/utils_tests/test_dateformat.py
@@ -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)