summaryrefslogtreecommitdiff
path: root/Lib/test/test_py3kwarn.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-08-24 18:10:20 +0000
committerBenjamin Peterson <benjamin@python.org>2008-08-24 18:10:20 +0000
commit712ee923092ef1b47c72914c5e2950be2f05f527 (patch)
tree9d6052ea7c1f7dc65c45568f847f762de71f8871 /Lib/test/test_py3kwarn.py
parenta403e4141afb5dfff41d5844e32d94bc7d341c17 (diff)
downloadcpython-git-712ee923092ef1b47c72914c5e2950be2f05f527.tar.gz
generate py3k warnings on __getslice__, __delslice__, and __setslice__
Reviewer: Brett Cannon
Diffstat (limited to 'Lib/test/test_py3kwarn.py')
-rw-r--r--Lib/test/test_py3kwarn.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index 274e147167..1b487fe53a 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -175,6 +175,28 @@ class TestPy3KWarnings(unittest.TestCase):
with catch_warning() as w:
self.assertWarning(set(), w, expected)
+ def test_slice_methods(self):
+ class Spam(object):
+ def __getslice__(self, i, j): pass
+ def __setslice__(self, i, j, what): pass
+ def __delslice__(self, i, j): pass
+ class Egg:
+ def __getslice__(self, i, h): pass
+ def __setslice__(self, i, j, what): pass
+ def __delslice__(self, i, j): pass
+
+ expected = "in 3.x, __{0}slice__ has been removed; use __{0}item__"
+
+ for obj in (Spam(), Egg()):
+ with catch_warning() as w:
+ self.assertWarning(obj[1:2], w, expected.format('get'))
+ w.reset()
+ del obj[3:4]
+ self.assertWarning(None, w, expected.format('del'))
+ w.reset()
+ obj[4:5] = "eggs"
+ self.assertWarning(None, w, expected.format('set'))
+
def test_tuple_parameter_unpacking(self):
expected = "tuple parameter unpacking has been removed in 3.x"
with catch_warning() as w: