diff options
author | Raymond Hettinger <python@rcn.com> | 2008-11-16 11:44:54 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-11-16 11:44:54 (GMT) |
commit | 7d99f09f89002d9afbf00befd7b2d78f4f9f17d8 (patch) | |
tree | 33150227e0381dea3bd9712c15e56ec0eaf19601 /Lib/test | |
parent | 4a1f593df5d4733831a1c4f03ca40c701433c43d (diff) | |
download | cpython-7d99f09f89002d9afbf00befd7b2d78f4f9f17d8.zip cpython-7d99f09f89002d9afbf00befd7b2d78f4f9f17d8.tar.gz cpython-7d99f09f89002d9afbf00befd7b2d78f4f9f17d8.tar.bz2 |
Issue #1721812: Binary operations and copy operations on set/frozenset
subclasses need to return the base type, not the subclass itself.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_set.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 614c9c0..07319fc 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -71,7 +71,7 @@ class TestJointOps(unittest.TestCase): for c in self.letters: self.assertEqual(c in u, c in self.d or c in self.otherword) self.assertEqual(self.s, self.thetype(self.word)) - self.assertEqual(type(u), self.thetype) + self.assertEqual(type(u), self.basetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) self.assertRaises(TypeError, self.s.union, [[]]) for C in set, frozenset, dict.fromkeys, str, list, tuple: @@ -97,7 +97,7 @@ class TestJointOps(unittest.TestCase): for c in self.letters: self.assertEqual(c in i, c in self.d and c in self.otherword) self.assertEqual(self.s, self.thetype(self.word)) - self.assertEqual(type(i), self.thetype) + self.assertEqual(type(i), self.basetype) self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) for C in set, frozenset, dict.fromkeys, str, list, tuple: self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc')) @@ -142,7 +142,7 @@ class TestJointOps(unittest.TestCase): for c in self.letters: self.assertEqual(c in i, c in self.d and c not in self.otherword) self.assertEqual(self.s, self.thetype(self.word)) - self.assertEqual(type(i), self.thetype) + self.assertEqual(type(i), self.basetype) self.assertRaises(PassThru, self.s.difference, check_pass_thru()) self.assertRaises(TypeError, self.s.difference, [[]]) for C in set, frozenset, dict.fromkeys, str, list, tuple: @@ -169,7 +169,7 @@ class TestJointOps(unittest.TestCase): for c in self.letters: self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword)) self.assertEqual(self.s, self.thetype(self.word)) - self.assertEqual(type(i), self.thetype) + self.assertEqual(type(i), self.basetype) self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) for C in set, frozenset, dict.fromkeys, str, list, tuple: @@ -325,6 +325,7 @@ class TestJointOps(unittest.TestCase): class TestSet(TestJointOps): thetype = set + basetype = set def test_init(self): s = self.thetype() @@ -357,6 +358,7 @@ class TestSet(TestJointOps): dup = self.s.copy() self.assertEqual(self.s, dup) self.assertNotEqual(id(self.s), id(dup)) + self.assertEqual(type(dup), self.basetype) def test_add(self): self.s.add('Q') @@ -595,6 +597,7 @@ class SetSubclass(set): class TestSetSubclass(TestSet): thetype = SetSubclass + basetype = set class SetSubclassWithKeywordArgs(set): def __init__(self, iterable=[], newarg=None): @@ -608,6 +611,7 @@ class TestSetSubclassWithKeywordArgs(TestSet): class TestFrozenSet(TestJointOps): thetype = frozenset + basetype = frozenset def test_init(self): s = self.thetype(self.word) @@ -673,6 +677,7 @@ class FrozenSetSubclass(frozenset): class TestFrozenSetSubclass(TestFrozenSet): thetype = FrozenSetSubclass + basetype = frozenset def test_constructor_identity(self): s = self.thetype(range(3)) |