Skip to content

Commit 2946c54

Browse files
authored
[3.14] gh-149221: Add missing test_binomialvariate_log_zero (#154879)
1 parent f9f44dd commit 2946c54

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_random.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,13 @@ def test_avg_std(self):
10741074
self.assertAlmostEqual(s2/(N-1), sigmasqrd, places=2,
10751075
msg='%s%r' % (variate.__name__, args))
10761076

1077+
def test_binomialvariate_log_zero(self):
1078+
# gh-149222: Variety random() return 0.0 no input Error
1079+
with unittest.mock.patch.object(random.Random, 'random', side_effect=[0.0] + [0.5] * 20):
1080+
result = random.binomialvariate(10, 0.5)
1081+
self.assertIsInstance(result, int)
1082+
self.assertIn(result, range(11))
1083+
10771084
def test_binomialvariate_btrs_random_zero(self):
10781085
for p, expected in ((0.25, 25), (0.75, 75)):
10791086
with self.subTest(p=p):

0 commit comments

Comments
 (0)