summaryrefslogtreecommitdiff
path: root/fs/tests
diff options
context:
space:
mode:
authorwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2012-01-30 15:11:42 +0000
committerwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2012-01-30 15:11:42 +0000
commitb2ca4cd1190dc38726f9b9e28995ae61a7de2c39 (patch)
treea5bea799a551e641b387163aacf4fc1a589767aa /fs/tests
parent5d80a31f33f7206805583b6ee4c6dec0ef54e629 (diff)
downloadpyfilesystem-git-b2ca4cd1190dc38726f9b9e28995ae61a7de2c39.tar.gz
Added regression test for zip file open bug
Diffstat (limited to 'fs/tests')
-rw-r--r--fs/tests/zipfs_binary_test.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/fs/tests/zipfs_binary_test.py b/fs/tests/zipfs_binary_test.py
new file mode 100644
index 0000000..35e2dc1
--- /dev/null
+++ b/fs/tests/zipfs_binary_test.py
@@ -0,0 +1,43 @@
+"""
+Test case for ZipFS binary file reading/writing
+Passes ok on Linux, fails on Windows (tested: Win7, 64-bit):
+
+AssertionError: ' \r\n' != ' \n'
+"""
+
+import unittest
+from fs.zipfs import ZipFS
+import os
+
+class ZipFsBinaryWriteRead(unittest.TestCase):
+ test_content = chr(32) + chr(10)
+
+ def setUp(self):
+ self.z = ZipFS('test.zip', 'w')
+
+ def tearDown(self):
+ try:
+ os.remove('test.zip')
+ except:
+ pass
+
+ def test_binary_write_read(self):
+ # GIVEN zipfs
+ z = self.z
+
+ # WHEN binary data is written to a test file in zipfs
+ f = z.open('test.data', 'wb')
+ f.write(self.test_content)
+ f.close()
+ z.close()
+
+ # THEN the same binary data is retrieved when opened again
+ z = ZipFS('test.zip', 'r')
+ f = z.open('test.data', 'rb')
+ content = f.read()
+ f.close()
+ z.close()
+ self.assertEqual(content, self.test_content)
+
+if __name__ == '__main__':
+ unittest.main()