Skip to content

Commit 62c54ca

Browse files
committed
zipfs tests
1 parent 2df7a06 commit 62c54ca

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
8+
## [2.0.2] - 2017-03.12
9+
10+
### Changed
11+
Improved FTP support for non-compliant servers
12+
Fix for ZipFS implied directories
13+
714
## [2.0.1] - 2017-03-11
815

916
### Added

fs/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.2a0"
1+
__version__ = "2.0.2"

tests/test_archives.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,8 @@ def test_walk_files(self):
126126
source_files,
127127
archive_files
128128
)
129+
130+
def test_implied_dir(self):
131+
self.fs.getinfo('foo/bar')
132+
self.fs.getinfo('foo')
133+

tests/test_zipfs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import tempfile
55
import unittest
6+
import zipfile
67

78
from fs import zipfs
89
from fs.compress import write_zip
@@ -52,3 +53,25 @@ class TestReadZipFSMem(TestReadZipFS):
5253

5354
def make_source_fs(self):
5455
return open_fs('mem://')
56+
57+
58+
class TestDirsZipFS(unittest.TestCase):
59+
60+
def test_implied(self):
61+
"""Test zipfs creates intermediate directories."""
62+
fh, path = tempfile.mkstemp('testzip.zip')
63+
try:
64+
os.close(fh)
65+
_zip_file = zipfile.ZipFile(path, mode='w')
66+
_zip_file.writestr('foo/bar/baz/egg', b'hello')
67+
_zip_file.close()
68+
zip_fs = zipfs.ZipFS(path)
69+
zip_fs.getinfo('foo')
70+
zip_fs.getinfo('foo/bar')
71+
zip_fs.getinfo('foo/bar/baz')
72+
self.assertTrue(zip_fs.isdir('foo/bar/baz'))
73+
self.assertTrue(zip_fs.isfile('foo/bar/baz/egg'))
74+
finally:
75+
os.remove(path)
76+
77+

0 commit comments

Comments
 (0)