diff options
author | William Schwartz <wkschwartz@gmail.com> | 2021-01-16 17:22:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-16 17:22:21 (GMT) |
commit | f08c66467d56c71f75c6659ede9177449fe9d2e6 (patch) | |
tree | 54a275d9fb9e807c0ea5762c9f987727e118bb97 /Lib/test | |
parent | 187f76def8a5bd0af7ab512575cad30cfe624b05 (diff) | |
download | cpython-f08c66467d56c71f75c6659ede9177449fe9d2e6.zip cpython-f08c66467d56c71f75c6659ede9177449fe9d2e6.tar.gz cpython-f08c66467d56c71f75c6659ede9177449fe9d2e6.tar.bz2 |
[3.8] bpo-42531: Teach importlib.resources.path to handle packages without __file__ (GH-23611)
Fixes [bpo-42531]() for Python 3.8.
The issue also applies to 3.7. If this PR looks like it'll be accepted, I can cherry-pick it to the 3.7 branch and submit a follow-up PR.
Automerge-Triggered-By: GH:jaraco
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_importlib/test_path.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/test_path.py b/Lib/test/test_importlib/test_path.py index 2d3dcda..5c5a8e3 100644 --- a/Lib/test/test_importlib/test_path.py +++ b/Lib/test/test_importlib/test_path.py @@ -1,3 +1,4 @@ +import io import unittest from importlib import resources @@ -27,6 +28,17 @@ class PathDiskTests(PathTests, unittest.TestCase): data = data01 +class PathMemoryTests(PathTests, unittest.TestCase): + def setUp(self): + file = io.BytesIO(b'Hello, UTF-8 world!\n') + self.addCleanup(file.close) + self.data = util.create_package( + file=file, path=FileNotFoundError("package exists only in memory") + ) + self.data.__spec__.origin = None + self.data.__spec__.has_location = False + + 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 |