Skip to content

Commit e18b2d0

Browse files
committed
Close the zipfiles in test_at and test_str.
CPython now emits a ResourceWarning when a writable ZipFile is closed implicitly (python/cpython#152354).
1 parent 7dff886 commit e18b2d0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎tests/test_path.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,17 @@ class Subclass(zipfile.Path):
351351
assert isinstance(root / 'b', Subclass)
352352

353353
def test_at(self):
354-
root = zipfile.Path(zipfile.ZipFile(io.BytesIO(), 'w'))
354+
zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), 'w'))
355+
root = zipfile.Path(zip_file)
355356
assert root.at == ''
356357
assert (root / 'foo' / 'bar').at == 'foo/bar'
357358

358359
def test_str(self):
359360
"""
360361
An unnamed zip file is indicated by ":zipfile:"
361362
"""
362-
root = zipfile.Path(zipfile.ZipFile(io.BytesIO(), 'w'))
363+
zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), 'w'))
364+
root = zipfile.Path(zip_file)
363365
assert str(root) == ':zipfile:'
364366
assert str(root / 'foo' / 'bar') == ':zipfile:/foo/bar'
365367

0 commit comments

Comments
 (0)