diff options
| -rw-r--r-- | pyramid/scripts/pserve.py | 5 | ||||
| -rw-r--r-- | pyramid/tests/test_path.py | 7 | ||||
| -rw-r--r-- | pyramid/tests/test_scripts/test_pserve.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_static.py | 2 |
4 files changed, 14 insertions, 2 deletions
diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py index 087549cd2..c2df7162f 100644 --- a/pyramid/scripts/pserve.py +++ b/pyramid/scripts/pserve.py @@ -581,6 +581,11 @@ class LazyWriter(object): self.lock.release() return self.fileobj + def __del__(self): + fileobj = self.fileobj + if fileobj is not None: + fileobj.close() + def write(self, text): fileobj = self.open() fileobj.write(text) diff --git a/pyramid/tests/test_path.py b/pyramid/tests/test_path.py index 304afad7c..42b38d785 100644 --- a/pyramid/tests/test_path.py +++ b/pyramid/tests/test_path.py @@ -283,7 +283,8 @@ class TestPkgResourcesAssetDescriptor(unittest.TestCase): inst = self._makeOne() inst.pkg_resources = DummyPkgResource() inst.pkg_resources.resource_stream = lambda x, y: '%s:%s' % (x, y) - self.assertEqual(inst.stream(), + s = inst.stream() + self.assertEqual(s, '%s:%s' % ('pyramid.tests', 'test_asset.py')) def test_isdir(self): @@ -337,7 +338,9 @@ class TestFSAssetDescriptor(unittest.TestCase): def test_stream(self): inst = self._makeOne() - val = inst.stream().read() + s = inst.stream() + val = s.read() + s.close() self.assertTrue(b'asset' in val) def test_isdir_False(self): diff --git a/pyramid/tests/test_scripts/test_pserve.py b/pyramid/tests/test_scripts/test_pserve.py index fe489aa66..d19eb6901 100644 --- a/pyramid/tests/test_scripts/test_pserve.py +++ b/pyramid/tests/test_scripts/test_pserve.py @@ -87,6 +87,7 @@ class TestLazyWriter(unittest.TestCase): inst = self._makeOne(filename) fp = inst.open() self.assertEqual(fp.name, filename) + fp.close() finally: os.remove(filename) @@ -122,6 +123,7 @@ class TestLazyWriter(unittest.TestCase): inst.flush() fp = inst.fileobj self.assertEqual(fp.name, filename) + fp.close() finally: os.remove(filename) diff --git a/pyramid/tests/test_static.py b/pyramid/tests/test_static.py index 3d6fbe893..109f82cbf 100644 --- a/pyramid/tests/test_static.py +++ b/pyramid/tests/test_static.py @@ -185,6 +185,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): self.assertEqual(response.status, '200 OK') self.assertEqual(response.content_type, 'application/x-tar') self.assertEqual(response.content_encoding, 'gzip') + response.app_iter.close() def test_resource_no_content_encoding(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -194,6 +195,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): self.assertEqual(response.status, '200 OK') self.assertEqual(response.content_type, 'text/html') self.assertEqual(response.content_encoding, None) + response.app_iter.close() class Test_static_view_use_subpath_True(unittest.TestCase): def _getTargetClass(self): |
