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

Unified Diff: Lib/test/pickletester.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 | « no previous file | Lib/test/test_abc.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/pickletester.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/pickletester.py Fri Feb 07 23:40:05 2014 +0200
@@ -645,7 +645,7 @@
x = self.loads(s)
self.assertIsInstance(x, list)
self.assertEqual(len(x), 1)
- self.assertTrue(x is x[0])
+ self.assertIs(x, x[0])
def test_recursive_tuple(self):
t = ([],)
@@ -656,7 +656,7 @@
self.assertIsInstance(x, tuple)
self.assertEqual(len(x), 1)
self.assertEqual(len(x[0]), 1)
- self.assertTrue(x is x[0][0])
+ self.assertIs(x, x[0][0])
def test_recursive_dict(self):
d = {}
@@ -666,7 +666,7 @@
x = self.loads(s)
self.assertIsInstance(x, dict)
self.assertEqual(list(x.keys()), [1])
- self.assertTrue(x[1] is x)
+ self.assertIs(x[1], x)
def test_recursive_set(self):
h = H()
@@ -713,7 +713,7 @@
self.assertEqual(len(x), 1)
self.assertEqual(dir(x[0]), dir(i))
self.assertEqual(list(x[0].attr.keys()), [1])
- self.assertTrue(x[0].attr[1] is x)
+ self.assertIs(x[0].attr[1], x)
def test_get(self):
self.assertRaises(KeyError, self.loads, b'g0\np0')
@@ -982,9 +982,9 @@
for x in None, False, True:
s = self.dumps(x, proto)
y = self.loads(s)
- self.assertTrue(x is y, (proto, x, s, y))
+ self.assertIs(x, y, (proto, x, s, y))
expected = expected_opcode[min(proto, 3), x]
- self.assertTrue(opcode_in_pickle(expected, s))
+ self.assertEqual(opcode_in_pickle(expected, s), True)
def test_newobj_tuple(self):
x = MyTuple([1, 2, 3])
@@ -1102,7 +1102,7 @@
if proto == 0:
self.assertEqual(num_appends, 0)
else:
- self.assertTrue(num_appends >= 2)
+ self.assertGreaterEqual(num_appends, 2)
def test_dict_chunking(self):
n = 10 # too small to chunk
@@ -1125,7 +1125,7 @@
if proto == 0:
self.assertEqual(num_setitems, 0)
else:
- self.assertTrue(num_setitems >= 2)
+ self.assertGreaterEqual(num_setitems, 2)
def test_set_chunking(self):
n = 10 # too small to chunk
@@ -2068,7 +2068,7 @@
primed.memo.clear()
self.assertEqual(unpickled_data2, data)
- self.assertTrue(unpickled_data2 is unpickled_data1)
+ self.assertIs(unpickled_data2, unpickled_data1)
def test_reusing_unpickler_objects(self):
data1 = ["abcdefg", "abcdefg", 44]
« no previous file with comments | « no previous file | Lib/test/test_abc.py » ('j') | no next file with comments »

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