Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aba2b06

Browse files
committed
Give better failure messages in test_strptime (cf. issue #14113).
1 parent 83c4882 commit aba2b06

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

Lib/test/test_strptime.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def compare_against_time(self, testing, directive, tuple_position,
3838
comparison = testing[self.time_tuple[tuple_position]]
3939
self.assertIn(strftime_output, testing,
4040
"%s: not found in tuple" % error_msg)
41-
self.assertTrue(comparison == strftime_output,
42-
"%s: position within tuple incorrect; %s != %s" %
43-
(error_msg, comparison, strftime_output))
41+
self.assertEqual(comparison, strftime_output,
42+
"%s: position within tuple incorrect; %s != %s" %
43+
(error_msg, comparison, strftime_output))
4444

4545
def test_weekday(self):
4646
# Make sure that full and abbreviated weekday names are correct in
@@ -65,8 +65,8 @@ def test_am_pm(self):
6565
"AM/PM representation not in tuple")
6666
if self.time_tuple[3] < 12: position = 0
6767
else: position = 1
68-
self.assertTrue(strftime_output == self.LT_ins.am_pm[position],
69-
"AM/PM representation in the wrong position within the tuple")
68+
self.assertEqual(self.LT_ins.am_pm[position], strftime_output,
69+
"AM/PM representation in the wrong position within the tuple")
7070

7171
def test_timezone(self):
7272
# Make sure timezone is correct
@@ -86,17 +86,14 @@ def test_date_time(self):
8686
# output.
8787
magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)
8888
strftime_output = time.strftime("%c", magic_date)
89-
self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date_time,
90-
magic_date),
91-
"LC_date_time incorrect")
89+
self.assertEqual(time.strftime(self.LT_ins.LC_date_time, magic_date),
90+
strftime_output, "LC_date_time incorrect")
9291
strftime_output = time.strftime("%x", magic_date)
93-
self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date,
94-
magic_date),
95-
"LC_date incorrect")
92+
self.assertEqual(time.strftime(self.LT_ins.LC_date, magic_date),
93+
strftime_output, "LC_date incorrect")
9694
strftime_output = time.strftime("%X", magic_date)
97-
self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_time,
98-
magic_date),
99-
"LC_time incorrect")
95+
self.assertEqual(time.strftime(self.LT_ins.LC_time, magic_date),
96+
strftime_output, "LC_time incorrect")
10097
LT = _strptime.LocaleTime()
10198
LT.am_pm = ('', '')
10299
self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle "
@@ -168,8 +165,8 @@ def test_blankpattern(self):
168165
# Fixes bug #661354
169166
test_locale = _strptime.LocaleTime()
170167
test_locale.timezone = (frozenset(), frozenset())
171-
self.assertTrue(_strptime.TimeRE(test_locale).pattern("%Z") == '',
172-
"with timezone == ('',''), TimeRE().pattern('%Z') != ''")
168+
self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '',
169+
"with timezone == ('',''), TimeRE().pattern('%Z') != ''")
173170

174171
def test_matching_with_escapes(self):
175172
# Make sure a format that requires escaping of characters works
@@ -195,7 +192,7 @@ def test_whitespace_substitution(self):
195192
# so as to not allow to subpatterns to end up next to each other and
196193
# "steal" characters from each other.
197194
pattern = self.time_re.pattern('%j %H')
198-
self.assertTrue(not re.match(pattern, "180"))
195+
self.assertFalse(re.match(pattern, "180"))
199196
self.assertTrue(re.match(pattern, "18 0"))
200197

201198

0 commit comments

Comments
 (0)