[Python-3000-checkins] r56377 - python/branches/p3yk/Lib/test/test_grammar.py

collin.winter python-3000-checkins at python.org
Sat Jul 14 21:00:18 CEST 2007


Author: collin.winter
Date: Sat Jul 14 21:00:17 2007
New Revision: 56377

Modified:
   python/branches/p3yk/Lib/test/test_grammar.py
Log:
Add a basic example of dictcomps to test_grammar.

Modified: python/branches/p3yk/Lib/test/test_grammar.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_grammar.py	(original)
+++ python/branches/p3yk/Lib/test/test_grammar.py	Sat Jul 14 21:00:17 2007
@@ -704,6 +704,13 @@
         @class_decorator
         class G: pass
 
+    def testDictcomps(self):
+        # dictorsetmaker: ( (test ':' test (comp_for |
+        #                                   (',' test ':' test)* [','])) |
+        #                   (test (comp_for | (',' test)* [','])) )
+        nums = [1, 2, 3]
+        self.assertEqual({i:i+1 for i in nums}, {1: 2, 2: 3, 3: 4})
+
     def testListcomps(self):
         # list comprehension tests
         nums = [1, 2, 3, 4, 5]


More information about the Python-3000-checkins mailing list