diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-01-27 18:17:45 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-01-27 18:17:45 (GMT) |
commit | a56c467ac39ab1a6a2e9dc2fa41a9f573f989839 (patch) | |
tree | f65fc7d2a4359328f10c1dd9122a692e78e71e8a /Lib/test/test_unittest.py | |
parent | 191e850053128f726d6562e1d8306dfe5e4aa8aa (diff) | |
download | cpython-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/test/test_unittest.py')
-rw-r--r-- | Lib/test/test_unittest.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index 9c12205..38ceb9a 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -1103,7 +1103,7 @@ class Test_TestLoader(TestCase): # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromTestCase(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass @@ -1119,7 +1119,7 @@ class Test_TestLoader(TestCase): # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromModule(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1137,7 +1137,7 @@ class Test_TestLoader(TestCase): # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromName(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1155,7 +1155,7 @@ class Test_TestLoader(TestCase): # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromNames(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1175,7 +1175,7 @@ class Test_TestLoader(TestCase): # Does it actually affect getTestCaseNames()? def test_sortTestMethodsUsing__getTestCaseNames(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass @@ -1188,9 +1188,19 @@ class Test_TestLoader(TestCase): self.assertEqual(loader.getTestCaseNames(Foo), test_names) # "The default value is the built-in cmp() function" + # Since cmp is now defunct, we simply verify that the results + # occur in the same order as they would with the default sort. def test_sortTestMethodsUsing__default_value(self): loader = unittest.TestLoader() - self.failUnless(loader.sortTestMethodsUsing is cmp) + + class Foo(unittest.TestCase): + def test_2(self): pass + def test_3(self): pass + def test_1(self): pass + + test_names = ['test_2', 'test_3', 'test_1'] + self.assertEqual(loader.getTestCaseNames(Foo), sorted(test_names)) + # "it can be set to None to disable the sort." # |