summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_userstring.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-02-18 13:22:43 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-02-18 13:22:43 (GMT)
commitaf3b39a1823d57eca4034ce6879ab926f175595e (patch)
tree6f66deffcd98a72aa66e5ebf3da44b3fbb4155e0 /Lib/test/test_userstring.py
parent612df8e21ded5a6d7c0f6641f16422883c61b4d9 (diff)
downloadcpython-af3b39a1823d57eca4034ce6879ab926f175595e.zip
cpython-af3b39a1823d57eca4034ce6879ab926f175595e.tar.gz
cpython-af3b39a1823d57eca4034ce6879ab926f175595e.tar.bz2
Add support for negative indices in UserString.MutableString.__setitem__
and UserString.MutableString.__delitem__.
Diffstat (limited to 'Lib/test/test_userstring.py')
-rwxr-xr-xLib/test/test_userstring.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 95f1351..53114db 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -52,20 +52,20 @@ class MutableStringTest(UserStringTest):
def test_setitem(self):
s = self.type2test("foo")
- self.assertRaises(IndexError, s.__setitem__, -1, "bar")
+ self.assertRaises(IndexError, s.__setitem__, -4, "bar")
self.assertRaises(IndexError, s.__setitem__, 3, "bar")
+ s[-1] = "bar"
+ self.assertEqual(s, "fobar")
s[0] = "bar"
- self.assertEqual(s, "baroo")
- s[4] = "foo"
- self.assertEqual(s, "barofoo")
+ self.assertEqual(s, "barobar")
def test_delitem(self):
s = self.type2test("foo")
- self.assertRaises(IndexError, s.__delitem__, -1)
+ self.assertRaises(IndexError, s.__delitem__, -4)
self.assertRaises(IndexError, s.__delitem__, 3)
+ del s[-1]
+ self.assertEqual(s, "fo")
del s[0]
- self.assertEqual(s, "oo")
- del s[1]
self.assertEqual(s, "o")
del s[0]
self.assertEqual(s, "")