Skip to content

Commit

Permalink
zipfs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Mar 26, 2017
1 parent 2df7a06 commit 62c54ca
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [2.0.2] - 2017-03.12

### Changed
Improved FTP support for non-compliant servers
Fix for ZipFS implied directories

## [2.0.1] - 2017-03-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion fs/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.2a0"
__version__ = "2.0.2"
5 changes: 5 additions & 0 deletions tests/test_archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,8 @@ def test_walk_files(self):
source_files,
archive_files
)

def test_implied_dir(self):
self.fs.getinfo('foo/bar')
self.fs.getinfo('foo')

23 changes: 23 additions & 0 deletions tests/test_zipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import tempfile
import unittest
import zipfile

from fs import zipfs
from fs.compress import write_zip
Expand Down Expand Up @@ -52,3 +53,25 @@ class TestReadZipFSMem(TestReadZipFS):

def make_source_fs(self):
return open_fs('mem://')


class TestDirsZipFS(unittest.TestCase):

def test_implied(self):
"""Test zipfs creates intermediate directories."""
fh, path = tempfile.mkstemp('testzip.zip')
try:
os.close(fh)
_zip_file = zipfile.ZipFile(path, mode='w')
_zip_file.writestr('foo/bar/baz/egg', b'hello')
_zip_file.close()
zip_fs = zipfs.ZipFS(path)
zip_fs.getinfo('foo')
zip_fs.getinfo('foo/bar')
zip_fs.getinfo('foo/bar/baz')
self.assertTrue(zip_fs.isdir('foo/bar/baz'))
self.assertTrue(zip_fs.isfile('foo/bar/baz/egg'))
finally:
os.remove(path)


0 comments on commit 62c54ca

Please sign in to comment.