summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-12-19 00:21:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-12-19 00:21:06 (GMT)
commit3b63556d4afcc358cfc8cec3ff189de519ecfb56 (patch)
tree5ffdf2eb879e4161047ad33fc5a06a5fa2df7583 /Lib
parent85dfcf35304935521085253ce5573feab21177d5 (diff)
downloadcpython-3b63556d4afcc358cfc8cec3ff189de519ecfb56.zip
cpython-3b63556d4afcc358cfc8cec3ff189de519ecfb56.tar.gz
cpython-3b63556d4afcc358cfc8cec3ff189de519ecfb56.tar.bz2
Beef-up tests for dict literals
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dict.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 342e775..b47e43d 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1,7 +1,7 @@
import unittest
from test import test_support
-import sys, UserDict, cStringIO
+import sys, UserDict, cStringIO, random, string
class DictTest(unittest.TestCase):
@@ -10,6 +10,15 @@ class DictTest(unittest.TestCase):
self.assertEqual(dict(), {})
self.assert_(dict() is not {})
+ def test_literal_constructor(self):
+ # check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg
+ items = []
+ for n in range(400):
+ dictliteral = '{' + ', '.join('%r: %d' % item for item in items) + '}'
+ self.assertEqual(eval(dictliteral), dict(items))
+ items.append((''.join([random.choice(string.letters) for j in range(8)]), n))
+ random.shuffle(items)
+
def test_bool(self):
self.assert_(not {})
self.assert_({1: 2})