Commit 210f84ba by willmcgugan

opener fix and tests

parent 57f82b67
...@@ -125,7 +125,7 @@ class _FSClosingFile(FileWrapper): ...@@ -125,7 +125,7 @@ class _FSClosingFile(FileWrapper):
"""A file like object that closes its parent FS when closed itself""" """A file like object that closes its parent FS when closed itself"""
def close(self): def close(self):
fs = getattr(self, '_closefs', None) fs = getattr(self, '_closefs', None)
ret = super(_FSClosingFile).close() ret = super(_FSClosingFile, self).close()
if fs is not None: if fs is not None:
fs.close fs.close
return ret return ret
......
"""
fs.tests.test_opener: testcases for FS opener
"""
import unittest
import tempfile
import shutil
from fs.opener import opener
from fs import path
class TestOpener(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.mkdtemp(u"fstest_opener")
def tearDown(self):
shutil.rmtree(self.temp_dir)
def testOpen(self):
filename = path.join(self.temp_dir, 'foo.txt')
file_object = opener.open(filename, 'wb')
file_object.close()
self.assertTrue(file_object.closed)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment