bpo-42772: Step argument ignored when stop is None. (GH-24018)

This commit is contained in:
Raymond Hettinger 2021-01-02 10:24:51 -08:00 committed by GitHub
parent 607501abb4
commit 768fa145cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -562,6 +562,14 @@ def test_randrange_argument_handling(self):
with self.assertRaises(ValueError):
randrange(10, 20, 1.5)
def test_randrange_step(self):
# bpo-42772: When stop is None, the step argument was being ignored.
randrange = self.gen.randrange
with self.assertRaises(TypeError):
randrange(1000, step=100)
with self.assertRaises(TypeError):
randrange(1000, None, step=100)
def test_randbelow_logic(self, _log=log, int=int):
# check bitcount transition points: 2**i and 2**(i+1)-1
# show that: k = int(1.001 + _log(n, 2))