summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_random.py
diff options
context:
space:
mode:
authorcsabella <chekat2@gmail.com>2017-05-11 15:19:35 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2017-05-11 15:19:35 (GMT)
commitf111fd2e65ef7aefd4ebeadbb48e84d609bf3733 (patch)
treee993f861a485a09e9b23b0092c25d92c5c15df8a /Lib/test/test_random.py
parent991adca012f5e106c2d4040ce619c696ba6f9c46 (diff)
downloadcpython-f111fd2e65ef7aefd4ebeadbb48e84d609bf3733.zip
cpython-f111fd2e65ef7aefd4ebeadbb48e84d609bf3733.tar.gz
cpython-f111fd2e65ef7aefd4ebeadbb48e84d609bf3733.tar.bz2
bpo-30308: Code coverage for argument in random.shuffle (#1504)
* bpo-30308: Code coverage for argument in random.shuffle * bpo-30308: Code coverage for argument in random.shuffle * bpo-30308: Code coverage for argument in random.shuffle
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r--Lib/test/test_random.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 48077fb..45468c7 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -9,6 +9,7 @@ from math import log, exp, pi, fsum, sin, factorial
from test import support
from fractions import Fraction
+
class TestBasicOps:
# Superclass with tests common to all generators.
# Subclasses must arrange for self.gen to retrieve the Random instance
@@ -50,7 +51,7 @@ class TestBasicOps:
@unittest.mock.patch('random._urandom') # os.urandom
def test_seed_when_randomness_source_not_found(self, urandom_mock):
# Random.seed() uses time.time() when an operating system specific
- # randomness source is not found. To test this on machines were it
+ # randomness source is not found. To test this on machines where it
# exists, run the above test, test_seedargs(), again after mocking
# os.urandom() so that it raises the exception expected when the
# randomness source is not available.
@@ -88,6 +89,15 @@ class TestBasicOps:
self.assertTrue(lst != shuffled_lst)
shuffle(lst)
self.assertTrue(lst != shuffled_lst)
+ self.assertRaises(TypeError, shuffle, (1, 2, 3))
+
+ def test_shuffle_random_argument(self):
+ # Test random argument to shuffle.
+ shuffle = self.gen.shuffle
+ mock_random = unittest.mock.Mock(return_value=0.5)
+ seq = bytearray(b'abcdefghijk')
+ shuffle(seq, mock_random)
+ mock_random.assert_called_with()
def test_choice(self):
choice = self.gen.choice