Mercurial > cpython-lru_cache-weakref
changeset 45837:c5241069fffd legacy-trunk
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.
| author | Jeffrey Yasskin <jyasskin@gmail.com> |
|---|---|
| date | Tue, 18 Mar 2008 05:12:41 +0000 |
| parents | 2546313a8b27 |
| children | 52682bd738a7 |
| files | Lib/test/test_dict.py |
| diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/test/test_dict.py Tue Mar 18 04:56:06 2008 +0000 +++ b/Lib/test/test_dict.py Tue Mar 18 05:12:41 2008 +0000 @@ -12,12 +12,14 @@ 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 {})
