Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(267485)

Unified Diff: Lib/test/test_strptime.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_ssl.py ('k') | Lib/test/test_symtable.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_strptime.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/test_strptime.py Fri Feb 07 23:40:05 2014 +0200
@@ -116,13 +116,13 @@
def test_pattern(self):
# Test TimeRE.pattern
pattern_string = self.time_re.pattern(r"%a %A %d")
- self.assertTrue(pattern_string.find(self.locale_time.a_weekday[2]) != -1,
+ self.assertNotEqual(pattern_string.find(self.locale_time.a_weekday[2]), -1,
"did not find abbreviated weekday in pattern string '%s'" %
pattern_string)
- self.assertTrue(pattern_string.find(self.locale_time.f_weekday[4]) != -1,
+ self.assertNotEqual(pattern_string.find(self.locale_time.f_weekday[4]), -1,
"did not find full weekday in pattern string '%s'" %
pattern_string)
- self.assertTrue(pattern_string.find(self.time_re['d']) != -1,
+ self.assertNotEqual(pattern_string.find(self.time_re['d']), -1,
"did not find 'd' directive pattern string '%s'" %
pattern_string)
@@ -250,7 +250,7 @@
for bound in bounds:
strp_output = _strptime._strptime_time(bound, '%y')
expected_result = century + int(bound)
- self.assertTrue(strp_output[0] == expected_result,
+ self.assertEqual(strp_output[0], expected_result,
"'y' test failed; passed in '%s' "
"and returned '%s'" % (bound, strp_output[0]))
@@ -268,7 +268,7 @@
self.helper('H', 3)
strf_output = time.strftime("%I %p", self.time_tuple)
strp_output = _strptime._strptime_time(strf_output, "%I %p")
- self.assertTrue(strp_output[3] == self.time_tuple[3],
+ self.assertEqual(strp_output[3], self.time_tuple[3],
"testing of '%%I %%p' directive failed; '%s' -> %s != %s" %
(strf_output, strp_output[3], self.time_tuple[3]))
@@ -310,11 +310,11 @@
strp_output = _strptime._strptime_time(strf_output, "%Z")
locale_time = _strptime.LocaleTime()
if time.tzname[0] != time.tzname[1] or not time.daylight:
- self.assertTrue(strp_output[8] == time_tuple[8],
+ self.assertEqual(strp_output[8], time_tuple[8],
"timezone check failed; '%s' -> %s != %s" %
(strf_output, strp_output[8], time_tuple[8]))
else:
- self.assertTrue(strp_output[8] == -1,
+ self.assertEqual(strp_output[8], -1,
"LocaleTime().timezone has duplicate values and "
"time.daylight but timezone value not set to -1")
@@ -375,7 +375,7 @@
# Default return value should be (1900, 1, 1, 0, 0, 0, 0, 1, 0)
defaults = (1900, 1, 1, 0, 0, 0, 0, 1, -1)
strp_output = _strptime._strptime_time('1', '%m')
- self.assertTrue(strp_output == defaults,
+ self.assertEqual(strp_output, defaults,
"Default values for strptime() are incorrect;"
" %s != %s" % (strp_output, defaults))
@@ -427,7 +427,7 @@
format_string = "%Y %m %d %H %M %S %w %Z"
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
- self.assertTrue(result.tm_yday == self.time_tuple.tm_yday,
+ self.assertEqual(result.tm_yday, self.time_tuple.tm_yday,
"Calculation of tm_yday failed; %s != %s" %
(result.tm_yday, self.time_tuple.tm_yday))
@@ -450,7 +450,7 @@
format_string = "%Y %m %d %H %S %j %Z"
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
- self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
+ self.assertEqual(result.tm_wday, self.time_tuple.tm_wday,
"Calculation of day of the week failed;"
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
@@ -463,7 +463,7 @@
dt_date = datetime_date(*ymd_tuple)
strp_input = dt_date.strftime(format_string)
strp_output = _strptime._strptime_time(strp_input, format_string)
- self.assertTrue(strp_output[:3] == ymd_tuple,
+ self.assertEqual(strp_output[:3], ymd_tuple,
"%s(%s) test failed w/ '%s': %s != %s (%s != %s)" %
(test_reason, directive, strp_input,
strp_output[:3], ymd_tuple,
« no previous file with comments | « Lib/test/test_ssl.py ('k') | Lib/test/test_symtable.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+