diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-19 02:59:17 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-19 02:59:17 (GMT) |
commit | 77badf32c9a9644dbfa470077cfe53d8ec5d0fdd (patch) | |
tree | c12ecf078cfd9f31a8badf37d3c90575728c6fe7 /Lib/test | |
parent | ba5da9437e766c2cbe12aef97ea6352fafaa75d5 (diff) | |
parent | ab5ba7918e07e5f3a7c51119e23803c755534a0d (diff) | |
download | cpython-77badf32c9a9644dbfa470077cfe53d8ec5d0fdd.zip cpython-77badf32c9a9644dbfa470077cfe53d8ec5d0fdd.tar.gz cpython-77badf32c9a9644dbfa470077cfe53d8ec5d0fdd.tar.bz2 |
#17790: merge with 3.3.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_set.py | 115 |
1 files changed, 31 insertions, 84 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index da62723..f8c7180 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -37,7 +37,7 @@ class HashCountingInt(int): 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 @@ class TestJointOps(unittest.TestCase): 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 @@ class TestSetSubclassWithKeywordArgs(TestSet): '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 @@ empty_set = set() #============================================================================== -class TestBasicOps(unittest.TestCase): +class TestBasicOps: def test_repr(self): if self.repr is not None: @@ -858,7 +858,7 @@ class TestBasicOps(unittest.TestCase): #------------------------------------------------------------------------------ -class TestBasicOpsEmpty(TestBasicOps): +class TestBasicOpsEmpty(TestBasicOps, unittest.TestCase): def setUp(self): self.case = "empty set" self.values = [] @@ -869,7 +869,7 @@ class TestBasicOpsEmpty(TestBasicOps): #------------------------------------------------------------------------------ -class TestBasicOpsSingleton(TestBasicOps): +class TestBasicOpsSingleton(TestBasicOps, unittest.TestCase): def setUp(self): self.case = "unit set (number)" self.values = [3] @@ -886,7 +886,7 @@ class TestBasicOpsSingleton(TestBasicOps): #------------------------------------------------------------------------------ -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 TestBasicOpsTuple(TestBasicOps): #------------------------------------------------------------------------------ -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 TestBasicOpsTriple(TestBasicOps): #------------------------------------------------------------------------------ -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 TestBasicOpsString(TestBasicOps): #------------------------------------------------------------------------------ -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 TestBasicOpsBytes(TestBasicOps): #------------------------------------------------------------------------------ -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 TestMutate(unittest.TestCase): #============================================================================== -class TestSubsets(unittest.TestCase): +class TestSubsets: case2method = {"<=": "issubset", ">=": "issuperset", @@ -1277,7 +1277,7 @@ class TestSubsets(unittest.TestCase): self.assertEqual(result, expected) #------------------------------------------------------------------------------ -class TestSubsetEqualEmpty(TestSubsets): +class TestSubsetEqualEmpty(TestSubsets, unittest.TestCase): left = set() right = set() name = "both empty" @@ -1285,7 +1285,7 @@ class TestSubsetEqualEmpty(TestSubsets): #------------------------------------------------------------------------------ -class TestSubsetEqualNonEmpty(TestSubsets): +class TestSubsetEqualNonEmpty(TestSubsets, unittest.TestCase): left = set([1, 2]) right = set([1, 2]) name = "equal pair" @@ -1293,7 +1293,7 @@ class TestSubsetEqualNonEmpty(TestSubsets): #------------------------------------------------------------------------------ -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 TestSubsetEmptyNonEmpty(TestSubsets): #------------------------------------------------------------------------------ -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 TestSubsetPartial(TestSubsets): #------------------------------------------------------------------------------ -class TestSubsetNonOverlap(TestSubsets): +class TestSubsetNonOverlap(TestSubsets, unittest.TestCase): left = set([1]) right = set([2]) name = "neither empty, neither contains" @@ -1317,7 +1317,7 @@ class TestSubsetNonOverlap(TestSubsets): #============================================================================== -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 TestOnlySetsInBinaryOps(unittest.TestCase): #------------------------------------------------------------------------------ -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 TestOnlySetsNumeric(TestOnlySetsInBinaryOps): #------------------------------------------------------------------------------ -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 TestOnlySetsDict(TestOnlySetsInBinaryOps): #------------------------------------------------------------------------------ -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 TestOnlySetsOperator(TestOnlySetsInBinaryOps): #------------------------------------------------------------------------------ -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 TestOnlySetsTuple(TestOnlySetsInBinaryOps): #------------------------------------------------------------------------------ -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 TestOnlySetsString(TestOnlySetsInBinaryOps): #------------------------------------------------------------------------------ -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 TestOnlySetsGenerator(TestOnlySetsInBinaryOps): #============================================================================== -class TestCopying(unittest.TestCase): +class TestCopying: def test_copy(self): dup = self.set.copy() @@ -1505,31 +1505,31 @@ class TestCopying(unittest.TestCase): #------------------------------------------------------------------------------ -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 @@ class TestGraphs(unittest.TestCase): #============================================================================== -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() |