MCPcopy Create free account
hub / github.com/python/cpython / test_gammavariate_alpha_equal_one

Method test_gammavariate_alpha_equal_one

Lib/test/test_random.py:1201–1209  ·  view source on GitHub ↗
(self, random_mock)

Source from the content-addressed store, hash-verified

1199
1200 @unittest.mock.patch('random.Random.random')
1201 def test_gammavariate_alpha_equal_one(self, random_mock):
1202
1203 # #2.a: alpha == 1.
1204 # The execution body of the while loop executes once.
1205 # Then random.random() returns 0.45,
1206 # which causes while to stop looping and the algorithm to terminate.
1207 random_mock.side_effect = [0.45]
1208 returned_value = random.gammavariate(1.0, 3.14)
1209 self.assertAlmostEqual(returned_value, 1.877208182372648)
1210
1211 @unittest.mock.patch('random.Random.random')
1212 def test_gammavariate_alpha_equal_one_equals_expovariate(self, random_mock):

Callers

nothing calls this directly

Calls 2

gammavariateMethod · 0.80
assertAlmostEqualMethod · 0.45

Tested by

no test coverage detected