summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_range.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-11-04 11:46:17 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-11-04 11:46:17 (GMT)
commit8cd1c7681d86fd3d32096f2d927d3f5014d58c36 (patch)
tree52d64e583436f496e89b4c5dfdf0884e860cf3ba /Lib/test/test_range.py
parentb87f82f8d46c8cd0fd4ab60f9680ca51ad3345bc (diff)
downloadcpython-8cd1c7681d86fd3d32096f2d927d3f5014d58c36.zip
cpython-8cd1c7681d86fd3d32096f2d927d3f5014d58c36.tar.gz
cpython-8cd1c7681d86fd3d32096f2d927d3f5014d58c36.tar.bz2
Issue #16402: In range slicing, fix shadowing of exceptions from __index__ method.
Diffstat (limited to 'Lib/test/test_range.py')
-rw-r--r--Lib/test/test_range.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index ede0791..4dab448 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -312,6 +312,15 @@ class RangeTest(unittest.TestCase):
self.assertRaises(TypeError, range, IN())
+ # Test use of user-defined classes in slice indices.
+ self.assertEqual(list(range(10)[:I(5)]), list(range(5)))
+
+ with self.assertRaises(RuntimeError):
+ range(0, 10)[:IX()]
+
+ with self.assertRaises(TypeError):
+ range(0, 10)[:IN()]
+
def test_count(self):
self.assertEqual(range(3).count(-1), 0)
self.assertEqual(range(3).count(0), 1)