mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
This commit is contained in:
parent
191e850053
commit
a56c467ac3
32 changed files with 210 additions and 216 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue