Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from

the standard library and tests.
This commit is contained in:
Mark Dickinson 2009-01-27 18:17:45 +00:00
parent 191e850053
commit a56c467ac3
32 changed files with 210 additions and 216 deletions

View file

@ -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)