Tighten-up the docs for Counter().

This commit is contained in:
Raymond Hettinger 2009-01-21 23:12:51 +00:00
parent 4571f347f9
commit 0a1f7b8f72
2 changed files with 26 additions and 25 deletions

View file

@ -448,6 +448,11 @@ class TestCounter(unittest.TestCase):
self.assertEqual(dict(Counter(s)), dict(Counter(s).items()))
self.assertEqual(set(Counter(s)), set(s))
def test_invariant_for_the_in_operator(self):
c = Counter(a=10, b=-2, c=0)
for elem in c:
self.assert_(elem in c)
def test_multiset_operations(self):
# Verify that adding a zero counter will strip zeros and negatives
c = Counter(a=10, b=-2, c=0) + Counter()