summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-12-07 09:25:05 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-12-07 09:25:05 (GMT)
commitc1ac194e94a3733b54723019e8495babbc57aa0a (patch)
tree60593343139155dd9cae14254350777bce19e252 /Lib/random.py
parentbabc83a27a6e692bbdaabd9aba7c65879d631dbc (diff)
downloadcpython-c1ac194e94a3733b54723019e8495babbc57aa0a.zip
cpython-c1ac194e94a3733b54723019e8495babbc57aa0a.tar.gz
cpython-c1ac194e94a3733b54723019e8495babbc57aa0a.tar.bz2
Clarify and speedup test.
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 16ec365..057571a 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.