summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index bafa23b..916a98f 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -935,7 +935,6 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000))
self.checkequal('a', 'abc', '__getitem__', slice(0, 1))
self.checkequal('', 'abc', '__getitem__', slice(0, 0))
- # FIXME What about negative indices? This is handled differently by [] and __getitem__(slice)
self.checkraises(TypeError, 'abc', '__getitem__', 'def')
@@ -949,10 +948,21 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('', 'abc', '__getslice__', 1000, 1000)
self.checkequal('', 'abc', '__getslice__', 2000, 1000)
self.checkequal('', 'abc', '__getslice__', 2, 1)
- # FIXME What about negative indizes? This is handled differently by [] and __getslice__
self.checkraises(TypeError, 'abc', '__getslice__', 'def')
+ def test_extended_getslice(self):
+ # Test extended slicing by comparing with list slicing.
+ s = string.ascii_letters + string.digits
+ indices = (0, None, 1, 3, 41, -1, -2, -37)
+ for start in indices:
+ for stop in indices:
+ # Skip step 0 (invalid)
+ for step in indices[1:]:
+ L = list(s)[start:stop:step]
+ self.checkequal("".join(L), s, '__getitem__',
+ slice(start, stop, step))
+
def test_mul(self):
self.checkequal('', 'abc', '__mul__', -1)
self.checkequal('', 'abc', '__mul__', 0)