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

Unified Diff: Lib/test/test_builtin.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 8 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_buffer.py ('k') | Lib/test/test_bz2.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_builtin.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/test_builtin.py Fri Feb 07 23:40:05 2014 +0200
@@ -153,7 +153,7 @@
self.assertEqual(abs(0), 0)
self.assertEqual(abs(1234), 1234)
self.assertEqual(abs(-1234), 1234)
- self.assertTrue(abs(-sys.maxsize-1) > 0)
+ self.assertGreater(abs(-sys.maxsize-1), 0)
# float
self.assertEqual(abs(0.0), 0.0)
self.assertEqual(abs(3.14), 3.14)
@@ -238,7 +238,7 @@
def test_neg(self):
x = -sys.maxsize-1
- self.assertTrue(isinstance(x, int))
+ self.assertIsInstance(x, int)
self.assertEqual(-x, sys.maxsize+1)
def test_callable(self):
@@ -298,7 +298,7 @@
self.assertRaises((OverflowError, ValueError), chr, 2**32)
def test_cmp(self):
- self.assertTrue(not hasattr(builtins, "cmp"))
+ self.assertFalse(hasattr(builtins, "cmp"))
def test_compile(self):
compile('print(1)\n', '', 'exec')
@@ -402,7 +402,7 @@
def __dir__(self):
return ["kan", "ga", "roo"]
f = Foo()
- self.assertTrue(dir(f) == ["ga", "kan", "roo"])
+ self.assertEqual(dir(f), ["ga", "kan", "roo"])
# dir(obj__dir__tuple)
class Foo(object):
@@ -410,7 +410,7 @@
return ("b", "c", "a")
res = dir(Foo())
self.assertIsInstance(res, list)
- self.assertTrue(res == ["a", "b", "c"])
+ self.assertEqual(res, ["a", "b", "c"])
# dir(obj__dir__not_sequence)
class Foo(object):
@@ -640,7 +640,7 @@
self.check_iter_pickle(f1, list(f2))
def test_getattr(self):
- self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
+ self.assertIs(getattr(sys, 'stdout'), sys.stdout)
self.assertRaises(TypeError, getattr, sys, 1)
self.assertRaises(TypeError, getattr, sys, 1, "foo")
self.assertRaises(TypeError, getattr)
@@ -721,11 +721,11 @@
c = C()
d = D()
e = E()
- self.assertTrue(isinstance(c, C))
- self.assertTrue(isinstance(d, C))
- self.assertTrue(not isinstance(e, C))
- self.assertTrue(not isinstance(c, D))
- self.assertTrue(not isinstance('foo', E))
+ self.assertIsInstance(c, C)
+ self.assertIsInstance(d, C)
+ self.assertNotIsInstance(e, C)
+ self.assertNotIsInstance(c, D)
+ self.assertNotIsInstance('foo', E)
self.assertRaises(TypeError, isinstance, E, 'foo')
self.assertRaises(TypeError, isinstance)
@@ -741,7 +741,7 @@
e = E()
self.assertTrue(issubclass(D, C))
self.assertTrue(issubclass(C, C))
- self.assertTrue(not issubclass(C, D))
+ self.assertFalse(issubclass(C, D))
self.assertRaises(TypeError, issubclass, 'foo', E)
self.assertRaises(TypeError, issubclass, E, 'foo')
self.assertRaises(TypeError, issubclass)
« no previous file with comments | « Lib/test/test_buffer.py ('k') | Lib/test/test_bz2.py » ('j') | no next file with comments »

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