aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dict.py')
-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 56ce722033a..53e6446a995 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
+import sys, UserDict, random, string
class DictTest(unittest.TestCase):
@@ -11,6 +11,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.ascii_letters) for j in range(8)]), n))
+ random.shuffle(items)
+
def test_bool(self):
self.assert_(not {})
self.assert_({1: 2})