summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing/iterfiletest.py
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-03-21 07:22:43 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-03-21 07:22:43 +0000
commit8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf (patch)
tree8f19be83962ef31d8ad58429d575c6f17d89c0ea /rdiff-backup/testing/iterfiletest.py
parent8259a0d8a9ad1396a93cd6320943dc33446ac6ed (diff)
downloadrdiff-backup-8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf.tar.gz
First checkin
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@2 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing/iterfiletest.py')
-rw-r--r--rdiff-backup/testing/iterfiletest.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/rdiff-backup/testing/iterfiletest.py b/rdiff-backup/testing/iterfiletest.py
new file mode 100644
index 0000000..38dca4d
--- /dev/null
+++ b/rdiff-backup/testing/iterfiletest.py
@@ -0,0 +1,27 @@
+import unittest, StringIO
+execfile("commontest.py")
+rbexec("iterfile.py")
+
+
+class testIterFile(unittest.TestCase):
+ def setUp(self):
+ self.iter1maker = lambda: iter(range(50))
+ self.iter2maker = lambda: iter(map(str, range(50)))
+
+ def testConversion(self):
+ """Test iter to file conversion"""
+ for itm in [self.iter1maker, self.iter2maker]:
+ assert Iter.equal(itm(),
+ IterWrappingFile(FileWrappingIter(itm())))
+
+class testBufferedRead(unittest.TestCase):
+ def testBuffering(self):
+ """Test buffering a StringIO"""
+ fp = StringIO.StringIO("12345678"*10000)
+ bfp = BufferedRead(fp)
+ assert bfp.read(5) == "12345"
+ assert bfp.read(4) == "6781"
+ assert len(bfp.read(75000)) == 75000
+
+
+if __name__ == "__main__": unittest.main()