summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-08-09 20:00:40 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-08-09 20:00:40 (GMT)
commitfcb393c0183c6a8cf47eb9575a1bbe6bc5d236e4 (patch)
tree51c5d45f70cd9946a373083bd31ddc2f109a9647 /Lib/test/test_collections.py
parent18205baf251495b5a54b08c1f9b0e1763eb27aa1 (diff)
downloadcpython-fcb393c0183c6a8cf47eb9575a1bbe6bc5d236e4.zip
cpython-fcb393c0183c6a8cf47eb9575a1bbe6bc5d236e4.tar.gz
cpython-fcb393c0183c6a8cf47eb9575a1bbe6bc5d236e4.tar.bz2
Add support for unary plus and unary minus to collections.Counter()
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index eb6d4d7..04c4d97 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -943,6 +943,11 @@ class TestCounter(unittest.TestCase):
c.subtract('aaaabbcce')
self.assertEqual(c, Counter(a=-1, b=0, c=-1, d=1, e=-1))
+ def test_unary(self):
+ c = Counter(a=-5, b=0, c=5, d=10, e=15,g=40)
+ self.assertEqual(dict(+c), dict(c=5, d=10, e=15, g=40))
+ self.assertEqual(dict(-c), dict(a=5))
+
def test_helper_function(self):
# two paths, one for real dicts and one for other mappings
elems = list('abracadabra')