diff options
Diffstat (limited to 'Lib/test/test_copy.py')
-rw-r--r-- | Lib/test/test_copy.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index 500fa83..133c888 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -2,10 +2,14 @@ import copy import copyreg - +from operator import le, lt, ge, gt, eq, ne import unittest from test import support +order_comparisons = le, lt, ge, gt +equality_comparisons = eq, ne +comparisons = order_comparisons + equality_comparisons + class TestCopy(unittest.TestCase): # Attempt full line coverage of copy.py from top to bottom @@ -271,7 +275,8 @@ class TestCopy(unittest.TestCase): x = [] x.append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + for op in comparisons: + self.assertRaises(RuntimeError, op, y, x) self.assert_(y is not x) self.assert_(y[0] is y) self.assertEqual(len(y), 1) @@ -287,7 +292,8 @@ class TestCopy(unittest.TestCase): x = ([],) x[0].append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + for op in comparisons: + self.assertRaises(RuntimeError, op, y, x) self.assert_(y is not x) self.assert_(y[0] is not x[0]) self.assert_(y[0][0] is y) @@ -303,7 +309,10 @@ class TestCopy(unittest.TestCase): x = {} x['foo'] = x y = copy.deepcopy(x) - self.assertRaises(TypeError, cmp, y, x) + for op in order_comparisons: + self.assertRaises(TypeError, op, y, x) + for op in equality_comparisons: + self.assertRaises(RuntimeError, op, y, x) self.assert_(y is not x) self.assert_(y['foo'] is y) self.assertEqual(len(y), 1) |