From c1ac194e94a3733b54723019e8495babbc57aa0a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 7 Dec 2002 09:25:05 +0000 Subject: Clarify and speedup test. --- Lib/random.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Lib/random.py') diff --git a/Lib/random.py b/Lib/random.py index 16ec3658ff..057571a1b2 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -774,8 +774,9 @@ def _test_sample(n): population = xrange(n) for k in xrange(n+1): s = sample(population, k) - assert len(dict([(elem,True) for elem in s])) == len(s) == k - assert None not in s + uniq = dict.fromkeys(s) + assert len(uniq) == len(s) == k + assert None not in uniq def _sample_generator(n, k): # Return a fixed element from the sample. Validates random ordering. -- cgit v1.2.1