Commit 56329054 authored by Evan Simpson's avatar Evan Simpson

Batch fixes.

parent cd0ac353
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
__doc__='''Batch class, for iterating over a sequence in batches __doc__='''Batch class, for iterating over a sequence in batches
$Id: Batch.py,v 1.3 2001/10/02 18:34:30 amos Exp $''' $Id: Batch.py,v 1.4 2001/10/02 20:54:49 evan Exp $'''
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
from ExtensionClass import Base from ExtensionClass import Base
...@@ -135,7 +135,7 @@ class Batch(Base): ...@@ -135,7 +135,7 @@ class Batch(Base):
if index + self.end < self.first: raise IndexError, index if index + self.end < self.first: raise IndexError, index
return self._sequence[index + self.end] return self._sequence[index + self.end]
if index >= self.size: raise IndexError, index if index >= self.length: raise IndexError, index
return self._sequence[index+self.first] return self._sequence[index+self.first]
def __len__(self): def __len__(self):
......
...@@ -11,6 +11,7 @@ ZTUtils changes ...@@ -11,6 +11,7 @@ ZTUtils changes
- Orphans defaulted to 3, which was confusing and out of sync - Orphans defaulted to 3, which was confusing and out of sync
with DTML-In. with DTML-In.
- Orphan batches were broken.
...@@ -33,11 +33,11 @@ class BatchTests(unittest.TestCase): ...@@ -33,11 +33,11 @@ class BatchTests(unittest.TestCase):
b = Batch(range(bsize), 5, orphan=3) b = Batch(range(bsize), 5, orphan=3)
assert b.next is None assert b.next is None
assert len(b) == bsize assert len(b) == bsize
assert b[bsize - 1] == bsize - 1
b = Batch(range(8), 5) b = Batch(range(8), 5)
assert len(b) == 5 assert len(b) == 5
assert len(b.next) == 3 assert len(b.next) == 3
def test_suite(): def test_suite():
return unittest.makeSuite(BatchTests) return unittest.makeSuite(BatchTests)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment