diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-12 16:24:08 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-12 16:24:08 +0000 |
commit | 61ef4309f5246529e09db428c2bfe5c3bb29a3a8 (patch) | |
tree | 921ee55e6911307a98bbf85c71f31746473f4099 /rdiff-backup/testing | |
parent | adc9d7a9a9cd90c8d078b1276cfdad98d0303d07 (diff) | |
download | rdiff-backup-61ef4309f5246529e09db428c2bfe5c3bb29a3a8.tar.gz |
Added CachedIndexableProcessor to rorpiter
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@279 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r-- | rdiff-backup/testing/rorpitertest.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/rdiff-backup/testing/rorpitertest.py b/rdiff-backup/testing/rorpitertest.py index 35f5916..acde06c 100644 --- a/rdiff-backup/testing/rorpitertest.py +++ b/rdiff-backup/testing/rorpitertest.py @@ -280,7 +280,8 @@ class CacheIndexableTest(unittest.TestCase): assert ci.get((3,)) == self.d[(3,)] assert ci.get((4,)) == self.d[(4,)] - assert ci.get((1,)) is None + assert ci.get((3,5)) is None + self.assertRaises(AssertionError, ci.get, (1,)) def testEqual(self): """Make sure CI doesn't alter properties of underlying iter""" @@ -288,7 +289,30 @@ class CacheIndexableTest(unittest.TestCase): l1 = list(self.get_iter()) l2 = list(rorpiter.CacheIndexable(iter(l1), 10)) assert l1 == l2, (l1, l2) - + + +class CacheIndexableProcessorTest(unittest.TestCase): + def function(self, elem): + """Called by CIP on each elem""" + self.l.append(elem) + + def testReorder(self): + """Test the reordering abilities of CIP""" + CIP = rorpiter.CachedIndexableProcessor(self.function, 3) + in_list = [rorpiter.IndexedTuple((x,), (x,)) for x in range(6)] + self.l = [] + + CIP(in_list[0]) + CIP(in_list[2]) + CIP(in_list[1]) + CIP(in_list[5]) + CIP(in_list[3]) + CIP(in_list[4]) + self.assertRaises(AssertionError, CIP, in_list[0]) + + CIP.close() + assert self.l == in_list, (self.l, in_list) + if __name__ == "__main__": unittest.main() |