Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(148)

Unified Diff: Lib/test/test_random.py

Issue 602: range: lean and mean (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: __len__ is back! Created 4 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side by-side-diff with in-line comments
Download patch
Index: Lib/test/test_random.py
===================================================================
--- Lib/test/test_random.py (revision 62635)
+++ Lib/test/test_random.py (working copy)
@@ -46,7 +46,7 @@
# For the entire allowable range of 0 <= k <= N, validate that
# the sample is of the correct length and contains only unique items
N = 100
- population = range(N)
+ population = list(range(N))
for k in range(N+1):
s = self.gen.sample(population, k)
self.assertEqual(len(s), k)
@@ -59,7 +59,7 @@
# For the entire allowable range of 0 <= k <= N, validate that
# sample generates all possible permutations
n = 5
- pop = range(n)
+ pop = list(range(n))
trials = 10000 # large num prevents false negatives without slowing normal case
def factorial(n):
if n == 0:
@@ -78,8 +78,8 @@
def test_sample_inputs(self):
# SF bug #801342 -- population can be any iterable defining __len__()
self.gen.sample(set(range(20)), 2)
- self.gen.sample(range(20), 2)
- self.gen.sample(range(20), 2)
+ self.gen.sample(list(range(20)), 2)
+ self.gen.sample(list(range(20)), 2)
self.gen.sample(str('abcdefghijklmnopqrst'), 2)
self.gen.sample(tuple('abcdefghijklmnopqrst'), 2)

Powered by Google App Engine
This is Rietveld r305