From 62c54ca2d0bd18b04be9f6a862cbf28f799cb999 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 26 Mar 2017 20:44:42 +0100 Subject: [PATCH] zipfs tests --- CHANGELOG.md | 7 +++++++ fs/_version.py | 2 +- tests/test_archives.py | 5 +++++ tests/test_zipfs.py | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 403e5a8f..c2a6a47c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/fs/_version.py b/fs/_version.py index 0d42fe04..0309ae29 100644 --- a/fs/_version.py +++ b/fs/_version.py @@ -1 +1 @@ -__version__ = "2.0.2a0" +__version__ = "2.0.2" diff --git a/tests/test_archives.py b/tests/test_archives.py index 5bfb3ca8..2c5b1b2c 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -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') + diff --git a/tests/test_zipfs.py b/tests/test_zipfs.py index c68288ee..f415a4ff 100644 --- a/tests/test_zipfs.py +++ b/tests/test_zipfs.py @@ -3,6 +3,7 @@ import os import tempfile import unittest +import zipfile from fs import zipfs from fs.compress import write_zip @@ -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) + +