summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_range.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-08 18:50:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-08 18:50:45 (GMT)
commitc7f490c8b19d5458d692f243279f7ad898f13ec4 (patch)
tree00696e8d0c669e8d4a413ecb04a8dae715aa59da /Lib/test/test_range.py
parent639098c5911b88f03972e7fd44fe230a651cbc9b (diff)
downloadcpython-c7f490c8b19d5458d692f243279f7ad898f13ec4.zip
cpython-c7f490c8b19d5458d692f243279f7ad898f13ec4.tar.gz
cpython-c7f490c8b19d5458d692f243279f7ad898f13ec4.tar.bz2
Issue #28376: Creating instances of range_iterator by calling range_iterator
type now is deprecated. Patch by Oren Milman.
Diffstat (limited to 'Lib/test/test_range.py')
-rw-r--r--Lib/test/test_range.py49
1 files changed, 26 insertions, 23 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index 7f1e985..9e11e51 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -499,29 +499,32 @@ class RangeTest(unittest.TestCase):
import _testcapi
rangeiter_type = type(iter(range(0)))
- # rangeiter_new doesn't take keyword arguments
- with self.assertRaises(TypeError):
- rangeiter_type(a=1)
-
- # rangeiter_new takes exactly 3 arguments
- self.assertRaises(TypeError, rangeiter_type)
- self.assertRaises(TypeError, rangeiter_type, 1)
- self.assertRaises(TypeError, rangeiter_type, 1, 1)
- self.assertRaises(TypeError, rangeiter_type, 1, 1, 1, 1)
-
- # start, stop and stop must fit in C long
- for good_val in [_testcapi.LONG_MAX, _testcapi.LONG_MIN]:
- rangeiter_type(good_val, good_val, good_val)
- for bad_val in [_testcapi.LONG_MAX + 1, _testcapi.LONG_MIN - 1]:
- self.assertRaises(OverflowError,
- rangeiter_type, bad_val, 1, 1)
- self.assertRaises(OverflowError,
- rangeiter_type, 1, bad_val, 1)
- self.assertRaises(OverflowError,
- rangeiter_type, 1, 1, bad_val)
-
- # step mustn't be zero
- self.assertRaises(ValueError, rangeiter_type, 1, 1, 0)
+ self.assertWarns(DeprecationWarning, rangeiter_type, 1, 3, 1)
+
+ with test.support.check_warnings(('', DeprecationWarning)):
+ # rangeiter_new doesn't take keyword arguments
+ with self.assertRaises(TypeError):
+ rangeiter_type(a=1)
+
+ # rangeiter_new takes exactly 3 arguments
+ self.assertRaises(TypeError, rangeiter_type)
+ self.assertRaises(TypeError, rangeiter_type, 1)
+ self.assertRaises(TypeError, rangeiter_type, 1, 1)
+ self.assertRaises(TypeError, rangeiter_type, 1, 1, 1, 1)
+
+ # start, stop and stop must fit in C long
+ for good_val in [_testcapi.LONG_MAX, _testcapi.LONG_MIN]:
+ rangeiter_type(good_val, good_val, good_val)
+ for bad_val in [_testcapi.LONG_MAX + 1, _testcapi.LONG_MIN - 1]:
+ self.assertRaises(OverflowError,
+ rangeiter_type, bad_val, 1, 1)
+ self.assertRaises(OverflowError,
+ rangeiter_type, 1, bad_val, 1)
+ self.assertRaises(OverflowError,
+ rangeiter_type, 1, 1, bad_val)
+
+ # step mustn't be zero
+ self.assertRaises(ValueError, rangeiter_type, 1, 1, 0)
def test_slice(self):
def check(start, stop, step=None):