diff --git a/Lib/random.py b/Lib/random.py index 88b8f6d701c..0886562a214 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -239,7 +239,11 @@ def _randbelow(self, n, int=int, _maxwidth=1< shuffle list x in place; return None. diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index f5c0030b190..08edeaddaa7 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -42,6 +42,13 @@ def test_seedargs(self): self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4) self.assertRaises(TypeError, type(self.gen), []) + def test_choice(self): + choice = self.gen.choice + with self.assertRaises(IndexError): + choice([]) + self.assertEqual(choice([50]), 50) + self.assertIn(choice([25, 75]), [25, 75]) + def test_sample(self): # For the entire allowable range of 0 <= k <= N, validate that # the sample is of the correct length and contains only unique items