diff options
author | gcode@loowis.durge.org <gcode@loowis.durge.org@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-12-23 02:37:32 +0000 |
---|---|---|
committer | gcode@loowis.durge.org <gcode@loowis.durge.org@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-12-23 02:37:32 +0000 |
commit | f25723a8f7c74a3b7c048c447e0e199f2e0b2457 (patch) | |
tree | 22f38e4584954b217e8b29d79f22c78ba345ee19 | |
parent | 621c6b81e6f49223179aa1c0d0ceae17d3e8f6c1 (diff) | |
download | pyfilesystem-f25723a8f7c74a3b7c048c447e0e199f2e0b2457.tar.gz |
Change the way TempFS's _meta dict gets built so that it 'inherits' default values from OSFS's _meta (eliminates duplicate code)
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@843 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r-- | fs/tempfs.py | 23 | ||||
-rw-r--r-- | fs/tests/test_fs.py | 7 |
2 files changed, 12 insertions, 18 deletions
diff --git a/fs/tempfs.py b/fs/tempfs.py index 8b5ec03..bc7d75f 100644 --- a/fs/tempfs.py +++ b/fs/tempfs.py @@ -22,24 +22,11 @@ class TempFS(OSFS): """Create a Filesystem in a temporary directory (with tempfile.mkdtemp), and removes it when the TempFS object is cleaned up.""" - _meta = { 'thread_safe' : True, - 'virtual' : False, - 'read_only' : False, - 'unicode_paths' : os.path.supports_unicode_filenames, - 'case_insensitive_paths' : os.path.normcase('Aa') == 'aa', - 'pickle_contents': False, - 'network' : False, - 'atomic.move' : True, - 'atomic.copy' : True, - 'atomic.makedir' : True, - 'atomic.rename' : True, - 'atomic.setcontents' : False - } - - if platform.system() == 'Windows': - _meta["invalid_path_chars"] = ''.join(chr(n) for n in xrange(31)) + '\\:*?"<>|' - else: - _meta["invalid_path_chars"] = '\0' + _meta = dict(OSFS._meta) + _meta['pickle_contents'] = False + _meta['network'] = False + _meta['atomic.move'] = True + _meta['atomic.copy'] = True def __init__(self, identifier=None, temp_dir=None, dir_mode=0700, thread_synchronize=_thread_synchronize_default): """Creates a temporary Filesystem diff --git a/fs/tests/test_fs.py b/fs/tests/test_fs.py index e54b8ac..8823523 100644 --- a/fs/tests/test_fs.py +++ b/fs/tests/test_fs.py @@ -124,3 +124,10 @@ class TestTempFS(unittest.TestCase,FSTestCases,ThreadingTestCases): td = self.fs._temp_dir return os.path.exists(os.path.join(td, relpath(p))) + def test_invalid_chars(self): + super(TestTempFS, self).test_invalid_chars() + + self.assertRaises(errors.InvalidCharsInPathError, self.fs.open, 'invalid\0file', 'wb') + self.assertFalse(self.fs.isvalidpath('invalid\0file')) + self.assert_(self.fs.isvalidpath('validfile')) + self.assert_(self.fs.isvalidpath('completely_valid/path/foo.bar')) |