summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-01-25 21:02:04 (GMT)
committerGitHub <noreply@github.com>2021-01-25 21:02:04 (GMT)
commitf066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32 (patch)
treeb2d22c54e628f087d86e9dfb0330ede92eb4a260 /Lib/test
parenteb9983c59b0683270328b5c40a115bb028209511 (diff)
downloadcpython-f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32.zip
cpython-f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32.tar.gz
cpython-f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32.tar.bz2
bpo-37319: Improve documentation, code and tests of randrange. (GH-19112)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_random.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 35ae4e6..6690886 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -509,11 +509,24 @@ class SystemRandom_TestBasicOps(TestBasicOps, unittest.TestCase):
raises(-721)
raises(0, 100, -12)
# Non-integer start/stop
- raises(3.14159)
- raises(0, 2.71828)
+ self.assertWarns(DeprecationWarning, raises, 3.14159)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 3.0)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, Fraction(3, 1))
+ self.assertWarns(DeprecationWarning, raises, '3')
+ self.assertWarns(DeprecationWarning, raises, 0, 2.71828)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 2.0)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 0, Fraction(2, 1))
+ self.assertWarns(DeprecationWarning, raises, 0, '2')
# Zero and non-integer step
raises(0, 42, 0)
- raises(0, 42, 3.14159)
+ self.assertWarns(DeprecationWarning, raises, 0, 42, 0.0)
+ self.assertWarns(DeprecationWarning, raises, 0, 0, 0.0)
+ self.assertWarns(DeprecationWarning, raises, 0, 42, 3.14159)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, 3.0)
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, Fraction(3, 1))
+ self.assertWarns(DeprecationWarning, raises, 0, 42, '3')
+ self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, 1.0)
+ self.assertWarns(DeprecationWarning, raises, 0, 0, 1.0)
def test_randrange_argument_handling(self):
randrange = self.gen.randrange