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

Unified Diff: Lib/test/test_sys.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_sysconfig.py ('k') | Lib/test/test_telnetlib.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_sys.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/test_sys.py Fri Feb 07 23:40:05 2014 +0200
@@ -45,7 +45,7 @@
dh(None)
self.assertEqual(out.getvalue(), "")
- self.assertTrue(not hasattr(builtins, "_"))
+ self.assertFalse(hasattr(builtins, "_"))
dh(42)
self.assertEqual(out.getvalue(), "42\n")
self.assertEqual(builtins._, 42)
@@ -201,7 +201,7 @@
self.assertRaises(ValueError, sys.setswitchinterval, 0.0)
orig = sys.getswitchinterval()
# sanity check
- self.assertTrue(orig < 0.5, orig)
+ self.assertLess(orig, 0.5)
try:
for n in 0.00001, 0.05, 3.0, orig:
sys.setswitchinterval(n)
@@ -381,7 +381,7 @@
# Verify that the captured main-thread frame is _this_ frame.
frame = d.pop(main_id)
- self.assertTrue(frame is sys._getframe())
+ self.assertIs(frame, sys._getframe())
# Verify that the captured thread frame is blocked in g456, called
# from f123. This is a litte tricky, since various bits of
@@ -412,7 +412,7 @@
d = sys._current_frames()
self.assertEqual(len(d), 1)
self.assertIn(0, d)
- self.assertTrue(d[0] is sys._getframe())
+ self.assertIs(d[0], sys._getframe())
def test_attributes(self):
self.assertIsInstance(sys.api_version, int)
@@ -426,8 +426,8 @@
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.int_info), 2)
- self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
- self.assertTrue(sys.int_info.sizeof_digit >= 1)
+ self.assertEqual(sys.int_info.bits_per_digit % 5, 0)
+ self.assertGreaterEqual(sys.int_info.sizeof_digit, 1)
self.assertEqual(type(sys.int_info.bits_per_digit), int)
self.assertEqual(type(sys.int_info.sizeof_digit), int)
self.assertIsInstance(sys.hexversion, int)
@@ -489,7 +489,7 @@
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
- self.assertTrue(vi > (1,0,0))
+ self.assertGreater(vi, (1,0,0))
self.assertIsInstance(sys.float_repr_style, str)
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
if not sys.platform.startswith('win'):
@@ -513,9 +513,9 @@
numruns += 1
self.assertRaises(TypeError, sys.intern)
s = "never interned before" + str(numruns)
- self.assertTrue(sys.intern(s) is s)
+ self.assertIs(sys.intern(s), s)
s2 = s.swapcase().swapcase()
- self.assertTrue(sys.intern(s2) is s)
+ self.assertIs(sys.intern(s2), s)
# Subclasses of string can't be interned, because they
# provide too much opportunity for insane things to happen.
« no previous file with comments | « Lib/test/test_sysconfig.py ('k') | Lib/test/test_telnetlib.py » ('j') | no next file with comments »

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