Fix minor subclassing issue with collections.Counter

This commit is contained in:
Raymond Hettinger 2011-04-15 13:16:46 -07:00
parent 181810b5fe
commit 1c746c28f3
3 changed files with 13 additions and 2 deletions

View file

@ -680,6 +680,15 @@ class TestCounter(unittest.TestCase):
self.assertEqual(len(dup), len(words))
self.assertEqual(type(dup), type(words))
def test_copy_subclass(self):
class MyCounter(Counter):
pass
c = MyCounter('slartibartfast')
d = c.copy()
self.assertEqual(d, c)
self.assertEqual(len(d), len(c))
self.assertEqual(type(d), type(c))
def test_conversions(self):
# Convert to: set, list, dict
s = 'she sells sea shells by the sea shore'