summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-27 18:17:45 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-01-27 18:17:45 (GMT)
commita56c467ac39ab1a6a2e9dc2fa41a9f573f989839 (patch)
treef65fc7d2a4359328f10c1dd9122a692e78e71e8a /Lib/unittest.py
parent191e850053128f726d6562e1d8306dfe5e4aa8aa (diff)
downloadcpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.zip
cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.gz
cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.bz2
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index fec41ca..ffb8a6c 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -539,12 +539,16 @@ def CmpToKey(mycmp):
return mycmp(self.obj, other.obj) == -1
return K
+def three_way_cmp(x, y):
+ """Return -1 if x < y, 0 if x == y and 1 if x > y"""
+ return (x > y) - (x < y)
+
class TestLoader(object):
"""This class is responsible for loading tests according to various
criteria and returning them wrapped in a TestSuite
"""
testMethodPrefix = 'test'
- sortTestMethodsUsing = cmp
+ sortTestMethodsUsing = staticmethod(three_way_cmp)
suiteClass = TestSuite
def loadTestsFromTestCase(self, testCaseClass):