summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2006-03-29 09:13:13 (GMT)
committerRaymond Hettinger <python@rcn.com>2006-03-29 09:13:13 (GMT)
commit3c3346daa9bf900080428ed12b6d83aa04f7332b (patch)
tree08c345b00a41ebb40ee9bf4ade8cc3833cc7ba57 /Lib/test/test_random.py
parent62e97f023bf0c02f5f3c1a1552e8136c0b5c4cff (diff)
downloadcpython-3c3346daa9bf900080428ed12b6d83aa04f7332b.zip
cpython-3c3346daa9bf900080428ed12b6d83aa04f7332b.tar.gz
cpython-3c3346daa9bf900080428ed12b6d83aa04f7332b.tar.bz2
SF bug #1460340: random.sample can raise KeyError
Fix the hit and miss style of testing for sets and dicts.
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r--Lib/test/test_random.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 9c2e0d0..c9431b3 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -96,6 +96,9 @@ class TestBasicOps(unittest.TestCase):
self.gen.sample(dict.fromkeys('abcdefghijklmnopqrst'), 2)
self.gen.sample(str('abcdefghijklmnopqrst'), 2)
self.gen.sample(tuple('abcdefghijklmnopqrst'), 2)
+ # SF bug #1460340 -- random.sample can raise KeyError
+ a = dict.fromkeys(range(10)+range(10,100,2)+range(100,110))
+ self.gen.sample(a,3)
def test_gauss(self):
# Ensure that the seed() method initializes all the hidden state. In