The previous made the stop argument optional.

It is better to be explicit and just allow stop to be None.
This commit is contained in:
Raymond Hettinger 2003-05-02 19:44:20 +00:00
parent 14ef54cd83
commit 341deb74e7
3 changed files with 10 additions and 13 deletions

View file

@ -78,12 +78,12 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(list(islice(xrange(100), *args)), range(*tgtargs))
# Test stop=None
self.assertEqual(list(islice(xrange(10))), range(10))
self.assertEqual(list(islice(xrange(10), None)), range(10))
self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10))
self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2))
# Test invalid arguments
self.assertRaises(TypeError, islice, xrange(10))
self.assertRaises(TypeError, islice, xrange(10), 1, 2, 3, 4)
self.assertRaises(ValueError, islice, xrange(10), -5, 10, 1)
self.assertRaises(ValueError, islice, xrange(10), 1, -5, -1)