Issue #29061: secrets.randbelow() would hang with a negative input

This commit is contained in:
Raymond Hettinger 2016-12-29 22:54:25 -07:00
parent 9ea82ddad5
commit e9ee207622
4 changed files with 7 additions and 0 deletions

View file

@ -70,6 +70,7 @@ class Random_Tests(unittest.TestCase):
for i in range(2, 10):
self.assertIn(secrets.randbelow(i), range(i))
self.assertRaises(ValueError, secrets.randbelow, 0)
self.assertRaises(ValueError, secrets.randbelow, -1)
class Token_Tests(unittest.TestCase):