summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2008-03-18 05:12:41 (GMT)
committerJeffrey Yasskin <jyasskin@gmail.com>2008-03-18 05:12:41 (GMT)
commited414654c480b440679062c873953ab05a31c897 (patch)
tree6527335772ee2e5249b4b7458fac1e1895e430e0 /Lib
parenta14585308af777aa64ec7100472d3c3e2961a6e7 (diff)
downloadcpython-ed414654c480b440679062c873953ab05a31c897.zip
cpython-ed414654c480b440679062c873953ab05a31c897.tar.gz
cpython-ed414654c480b440679062c873953ab05a31c897.tar.bz2
Speed up test_dict by about 10x by only checking selected dict literal sizes,
instead of every integer from 0 to 400. Exhaustive testing wastes time without providing enough more assurance that the code is correct.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dict.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 7dd5f06..b62237d 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -12,12 +12,14 @@ class DictTest(unittest.TestCase):
def test_literal_constructor(self):
# check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg
- items = []
- for n in range(400):
+ for n in (0, 1, 6, 256, 400):
+ items = [(''.join([random.choice(string.letters)
+ for j in range(8)]),
+ i)
+ for i in range(n)]
+ random.shuffle(items)
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 {})