Update importlib-resources==5.4.0

This commit is contained in:
JonnyWong16 2021-11-28 13:54:44 -08:00
parent c79c48fcca
commit 563f697563
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
12 changed files with 167 additions and 125 deletions

View file

@ -8,7 +8,7 @@ from . import util
class CommonTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
with resources.path(package, path):
with resources.as_file(resources.files(package).joinpath(path)):
pass
@ -17,7 +17,8 @@ class PathTests:
# Path should be readable.
# Test also implicitly verifies the returned object is a pathlib.Path
# instance.
with resources.path(self.data, 'utf-8.file') as path:
target = resources.files(self.data) / 'utf-8.file'
with resources.as_file(target) as path:
self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
# pathlib.Path.read_text() was introduced in Python 3.5.
with path.open('r', encoding='utf-8') as file:
@ -34,7 +35,8 @@ class PathDiskTests(PathTests, unittest.TestCase):
file-system-backed resources do not get the tempdir
treatment.
"""
with resources.path(self.data, 'utf-8.file') as path:
target = resources.files(self.data) / 'utf-8.file'
with resources.as_file(target) as path:
assert 'data' in str(path)
@ -53,7 +55,8 @@ class PathZipTests(PathTests, util.ZipSetup, unittest.TestCase):
def test_remove_in_context_manager(self):
# It is not an error if the file that was temporarily stashed on the
# file system is removed inside the `with` stanza.
with resources.path(self.data, 'utf-8.file') as path:
target = resources.files(self.data) / 'utf-8.file'
with resources.as_file(target) as path:
path.unlink()