[Python-checkins] cpython (merge 3.3 -> default): #17790: merge with 3.3.

ezio.melotti python-checkins at python.org
Fri Apr 19 04:59:33 CEST 2013


http://hg.python.org/cpython/rev/8a0b3ece5c28
changeset:   83450:8a0b3ece5c28
parent:      83448:ac352d7d8058
parent:      83449:ef100be2e8ba
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Fri Apr 19 05:59:17 2013 +0300
summary:
  #17790: merge with 3.3.

files:
  Lib/test/test_set.py |  115 ++++++++----------------------
  Misc/NEWS            |    3 +
  2 files changed, 34 insertions(+), 84 deletions(-)


diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -37,7 +37,7 @@
         self.hash_count += 1
         return int.__hash__(self)
 
-class TestJointOps(unittest.TestCase):
+class TestJointOps:
     # Tests common to both set and frozenset
 
     def setUp(self):
@@ -361,7 +361,7 @@
         gc.collect()
         self.assertTrue(ref() is None, "Cycle was not collected")
 
-class TestSet(TestJointOps):
+class TestSet(TestJointOps, unittest.TestCase):
     thetype = set
     basetype = set
 
@@ -647,7 +647,7 @@
         'SF bug #1486663 -- this used to erroneously raise a TypeError'
         SetSubclassWithKeywordArgs(newarg=1)
 
-class TestFrozenSet(TestJointOps):
+class TestFrozenSet(TestJointOps, unittest.TestCase):
     thetype = frozenset
     basetype = frozenset
 
@@ -748,7 +748,7 @@
 
 #==============================================================================
 
-class TestBasicOps(unittest.TestCase):
+class TestBasicOps:
 
     def test_repr(self):
         if self.repr is not None:
@@ -858,7 +858,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsEmpty(TestBasicOps):
+class TestBasicOpsEmpty(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "empty set"
         self.values = []
@@ -869,7 +869,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsSingleton(TestBasicOps):
+class TestBasicOpsSingleton(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "unit set (number)"
         self.values = [3]
@@ -886,7 +886,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsTuple(TestBasicOps):
+class TestBasicOpsTuple(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "unit set (tuple)"
         self.values = [(0, "zero")]
@@ -903,7 +903,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsTriple(TestBasicOps):
+class TestBasicOpsTriple(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "triple set"
         self.values = [0, "zero", operator.add]
@@ -914,7 +914,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsString(TestBasicOps):
+class TestBasicOpsString(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "string set"
         self.values = ["a", "b", "c"]
@@ -927,7 +927,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsBytes(TestBasicOps):
+class TestBasicOpsBytes(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self.case   = "string set"
         self.values = [b"a", b"b", b"c"]
@@ -940,7 +940,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestBasicOpsMixedStringBytes(TestBasicOps):
+class TestBasicOpsMixedStringBytes(TestBasicOps, unittest.TestCase):
     def setUp(self):
         self._warning_filters = support.check_warnings()
         self._warning_filters.__enter__()
@@ -1239,7 +1239,7 @@
 
 #==============================================================================
 
-class TestSubsets(unittest.TestCase):
+class TestSubsets:
 
     case2method = {"<=": "issubset",
                    ">=": "issuperset",
@@ -1277,7 +1277,7 @@
                 self.assertEqual(result, expected)
 #------------------------------------------------------------------------------
 
-class TestSubsetEqualEmpty(TestSubsets):
+class TestSubsetEqualEmpty(TestSubsets, unittest.TestCase):
     left  = set()
     right = set()
     name  = "both empty"
@@ -1285,7 +1285,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestSubsetEqualNonEmpty(TestSubsets):
+class TestSubsetEqualNonEmpty(TestSubsets, unittest.TestCase):
     left  = set([1, 2])
     right = set([1, 2])
     name  = "equal pair"
@@ -1293,7 +1293,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestSubsetEmptyNonEmpty(TestSubsets):
+class TestSubsetEmptyNonEmpty(TestSubsets, unittest.TestCase):
     left  = set()
     right = set([1, 2])
     name  = "one empty, one non-empty"
@@ -1301,7 +1301,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestSubsetPartial(TestSubsets):
+class TestSubsetPartial(TestSubsets, unittest.TestCase):
     left  = set([1])
     right = set([1, 2])
     name  = "one a non-empty proper subset of other"
@@ -1309,7 +1309,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestSubsetNonOverlap(TestSubsets):
+class TestSubsetNonOverlap(TestSubsets, unittest.TestCase):
     left  = set([1])
     right = set([2])
     name  = "neither empty, neither contains"
@@ -1317,7 +1317,7 @@
 
 #==============================================================================
 
-class TestOnlySetsInBinaryOps(unittest.TestCase):
+class TestOnlySetsInBinaryOps:
 
     def test_eq_ne(self):
         # Unlike the others, this is testing that == and != *are* allowed.
@@ -1433,7 +1433,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsNumeric(TestOnlySetsInBinaryOps):
+class TestOnlySetsNumeric(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         self.set   = set((1, 2, 3))
         self.other = 19
@@ -1441,7 +1441,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsDict(TestOnlySetsInBinaryOps):
+class TestOnlySetsDict(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         self.set   = set((1, 2, 3))
         self.other = {1:2, 3:4}
@@ -1449,7 +1449,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
+class TestOnlySetsOperator(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         self.set   = set((1, 2, 3))
         self.other = operator.add
@@ -1457,7 +1457,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsTuple(TestOnlySetsInBinaryOps):
+class TestOnlySetsTuple(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         self.set   = set((1, 2, 3))
         self.other = (2, 4, 6)
@@ -1465,7 +1465,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsString(TestOnlySetsInBinaryOps):
+class TestOnlySetsString(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         self.set   = set((1, 2, 3))
         self.other = 'abc'
@@ -1473,7 +1473,7 @@
 
 #------------------------------------------------------------------------------
 
-class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
+class TestOnlySetsGenerator(TestOnlySetsInBinaryOps, unittest.TestCase):
     def setUp(self):
         def gen():
             for i in range(0, 10, 2):
@@ -1484,7 +1484,7 @@
 
 #==============================================================================
 
-class TestCopying(unittest.TestCase):
+class TestCopying:
 
     def test_copy(self):
         dup = self.set.copy()
@@ -1505,31 +1505,31 @@
 
 #------------------------------------------------------------------------------
 
-class TestCopyingEmpty(TestCopying):
+class TestCopyingEmpty(TestCopying, unittest.TestCase):
     def setUp(self):
         self.set = set()
 
 #------------------------------------------------------------------------------
 
-class TestCopyingSingleton(TestCopying):
+class TestCopyingSingleton(TestCopying, unittest.TestCase):
     def setUp(self):
         self.set = set(["hello"])
 
 #------------------------------------------------------------------------------
 
-class TestCopyingTriple(TestCopying):
+class TestCopyingTriple(TestCopying, unittest.TestCase):
     def setUp(self):
         self.set = set(["zero", 0, None])
 
 #------------------------------------------------------------------------------
 
-class TestCopyingTuple(TestCopying):
+class TestCopyingTuple(TestCopying, unittest.TestCase):
     def setUp(self):
         self.set = set([(1, 2)])
 
 #------------------------------------------------------------------------------
 
-class TestCopyingNested(TestCopying):
+class TestCopyingNested(TestCopying, unittest.TestCase):
     def setUp(self):
         self.set = set([((1, 2), (3, 4))])
 
@@ -1835,58 +1835,5 @@
 
 #==============================================================================
 
-def test_main(verbose=None):
-    test_classes = (
-        TestSet,
-        TestSetSubclass,
-        TestSetSubclassWithKeywordArgs,
-        TestFrozenSet,
-        TestFrozenSetSubclass,
-        TestSetOfSets,
-        TestExceptionPropagation,
-        TestBasicOpsEmpty,
-        TestBasicOpsSingleton,
-        TestBasicOpsTuple,
-        TestBasicOpsTriple,
-        TestBasicOpsString,
-        TestBasicOpsBytes,
-        TestBasicOpsMixedStringBytes,
-        TestBinaryOps,
-        TestUpdateOps,
-        TestMutate,
-        TestSubsetEqualEmpty,
-        TestSubsetEqualNonEmpty,
-        TestSubsetEmptyNonEmpty,
-        TestSubsetPartial,
-        TestSubsetNonOverlap,
-        TestOnlySetsNumeric,
-        TestOnlySetsDict,
-        TestOnlySetsOperator,
-        TestOnlySetsTuple,
-        TestOnlySetsString,
-        TestOnlySetsGenerator,
-        TestCopyingEmpty,
-        TestCopyingSingleton,
-        TestCopyingTriple,
-        TestCopyingTuple,
-        TestCopyingNested,
-        TestIdentities,
-        TestVariousIteratorArgs,
-        TestGraphs,
-        TestWeirdBugs,
-        )
-
-    support.run_unittest(*test_classes)
-
-    # verify reference counting
-    if verbose and hasattr(sys, "gettotalrefcount"):
-        import gc
-        counts = [None] * 5
-        for i in range(len(counts)):
-            support.run_unittest(*test_classes)
-            gc.collect()
-            counts[i] = sys.gettotalrefcount()
-        print(counts)
-
 if __name__ == "__main__":
-    test_main(verbose=True)
+    unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -134,6 +134,9 @@
 - Issue #12820: add tests for the xml.dom.minicompat module.
   Patch by John Chandler and Phil Connell.
 
+- Issue #17790: test_set now works with unittest test discovery.
+  Patch by Zachary Ware.
+
 - Issue #17789: test_random now works with unittest test discovery.
   Patch by Zachary Ware.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list