diff options
author | Petri Lehtinen <petri@digip.org> | 2011-11-05 21:20:57 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2011-11-05 21:24:31 (GMT) |
commit | c2f0a46111dfc9958d1c0428f688b8f625888c88 (patch) | |
tree | 982262d833eeaa814f91208372ea8b4d57a0c087 /Lib | |
parent | 4e6bf41934de08f62b22b90cda2e331eb4641dea (diff) | |
download | cpython-c2f0a46111dfc9958d1c0428f688b8f625888c88.zip cpython-c2f0a46111dfc9958d1c0428f688b8f625888c88.tar.gz cpython-c2f0a46111dfc9958d1c0428f688b8f625888c88.tar.bz2 |
Accept None as start and stop parameters for list.index() and tuple.index()
Closes #13340.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/list_tests.py | 7 | ||||
-rw-r--r-- | Lib/test/seq_tests.py | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index be054ea..ebf86c5 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -365,6 +365,13 @@ class CommonTest(seq_tests.CommonTest): self.assertEqual(u.index(0, 3), 3) self.assertEqual(u.index(0, 3, 4), 3) self.assertRaises(ValueError, u.index, 2, 0, -10) + self.assertEqual(u.index(1, None), 4) + self.assertEqual(u.index(1, None, None), 4) + self.assertEqual(u.index(1, 0, None), 4) + self.assertEqual(u.index(1, None, 6), 4) + self.assertRaises(ValueError, u.index, -1, 3) + self.assertRaises(ValueError, u.index, -1, 3, None) + self.assertRaises(ValueError, u.index, 1, None, 4) self.assertRaises(TypeError, u.index) diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py index f655c29..824ae01 100644 --- a/Lib/test/seq_tests.py +++ b/Lib/test/seq_tests.py @@ -361,6 +361,13 @@ class CommonTest(unittest.TestCase): self.assertEqual(u.index(0, 3), 3) self.assertEqual(u.index(0, 3, 4), 3) self.assertRaises(ValueError, u.index, 2, 0, -10) + self.assertEqual(u.index(1, None), 4) + self.assertEqual(u.index(1, None, None), 4) + self.assertEqual(u.index(1, 0, None), 4) + self.assertEqual(u.index(1, None, 6), 4) + self.assertRaises(ValueError, u.index, -1, 3) + self.assertRaises(ValueError, u.index, -1, 3, None) + self.assertRaises(ValueError, u.index, 1, None, 4) self.assertRaises(TypeError, u.index) |