summaryrefslogtreecommitdiff
path: root/Lib/test/test_strptime.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-02-29 00:22:09 +0200
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-02-29 00:22:09 +0200
commit9760cd928be35bef0ac436c77efd0efcc8b18587 (patch)
treec4c085d36b62a35042f82baeb9890e0099e8ecbc /Lib/test/test_strptime.py
parent08bb2d0a00714c69a26bbdc0b2a2cae910a0e7cb (diff)
downloadcpython-9760cd928be35bef0ac436c77efd0efcc8b18587.tar.gz
Give better failure messages in test_strptime (cf. issue #14113).
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r--Lib/test/test_strptime.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 89c08ede7b..98d759b9f1 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -38,9 +38,9 @@ class LocaleTime_Tests(unittest.TestCase):
comparison = testing[self.time_tuple[tuple_position]]
self.assertIn(strftime_output, testing,
"%s: not found in tuple" % error_msg)
- self.assertTrue(comparison == strftime_output,
- "%s: position within tuple incorrect; %s != %s" %
- (error_msg, comparison, strftime_output))
+ self.assertEqual(comparison, strftime_output,
+ "%s: position within tuple incorrect; %s != %s" %
+ (error_msg, comparison, strftime_output))
def test_weekday(self):
# Make sure that full and abbreviated weekday names are correct in
@@ -65,8 +65,8 @@ class LocaleTime_Tests(unittest.TestCase):
"AM/PM representation not in tuple")
if self.time_tuple[3] < 12: position = 0
else: position = 1
- self.assertTrue(strftime_output == self.LT_ins.am_pm[position],
- "AM/PM representation in the wrong position within the tuple")
+ self.assertEqual(self.LT_ins.am_pm[position], strftime_output,
+ "AM/PM representation in the wrong position within the tuple")
def test_timezone(self):
# Make sure timezone is correct
@@ -86,17 +86,14 @@ class LocaleTime_Tests(unittest.TestCase):
# output.
magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)
strftime_output = time.strftime("%c", magic_date)
- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date_time,
- magic_date),
- "LC_date_time incorrect")
+ self.assertEqual(time.strftime(self.LT_ins.LC_date_time, magic_date),
+ strftime_output, "LC_date_time incorrect")
strftime_output = time.strftime("%x", magic_date)
- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date,
- magic_date),
- "LC_date incorrect")
+ self.assertEqual(time.strftime(self.LT_ins.LC_date, magic_date),
+ strftime_output, "LC_date incorrect")
strftime_output = time.strftime("%X", magic_date)
- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_time,
- magic_date),
- "LC_time incorrect")
+ self.assertEqual(time.strftime(self.LT_ins.LC_time, magic_date),
+ strftime_output, "LC_time incorrect")
LT = _strptime.LocaleTime()
LT.am_pm = ('', '')
self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle "
@@ -168,8 +165,8 @@ class TimeRETests(unittest.TestCase):
# Fixes bug #661354
test_locale = _strptime.LocaleTime()
test_locale.timezone = (frozenset(), frozenset())
- self.assertTrue(_strptime.TimeRE(test_locale).pattern("%Z") == '',
- "with timezone == ('',''), TimeRE().pattern('%Z') != ''")
+ self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '',
+ "with timezone == ('',''), TimeRE().pattern('%Z') != ''")
def test_matching_with_escapes(self):
# Make sure a format that requires escaping of characters works
@@ -195,7 +192,7 @@ class TimeRETests(unittest.TestCase):
# so as to not allow to subpatterns to end up next to each other and
# "steal" characters from each other.
pattern = self.time_re.pattern('%j %H')
- self.assertTrue(not re.match(pattern, "180"))
+ self.assertFalse(re.match(pattern, "180"))
self.assertTrue(re.match(pattern, "18 0"))