Skip to content

Commit 5c37a7e

Browse files
committed
Merge branch 'master' into 'bugfix/121-unicode-error-on-fastpath'
# Conflicts: # importlib_metadata/docs/changelog.rst
2 parents b4f4f60 + 8d38b1c commit 5c37a7e

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

importlib_metadata/docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ v1.6.1
66
======
77

88
* Ensure inputs to FastPath are Unicode. Closes #121.
9+
* Tests now rely on ``importlib.resources.files`` (and
10+
backport) instead of the older ``path`` function.
911

1012
v1.6.0
1113
======

importlib_metadata/docs/using.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The ``group`` and ``name`` are arbitrary values defined by the package author
9595
and usually a client will wish to resolve all entry points for a particular
9696
group. Read `the setuptools docs
9797
<https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins>`_
98-
for more information on entrypoints, their definition, and usage.
98+
for more information on entry points, their definition, and usage.
9999

100100

101101
.. _metadata:

importlib_metadata/tests/test_zip.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
)
88

99
try:
10-
from importlib.resources import path
11-
except ImportError:
12-
from importlib_resources import path
10+
from importlib import resources
11+
getattr(resources, 'files')
12+
getattr(resources, 'as_file')
13+
except (ImportError, AttributeError):
14+
import importlib_resources as resources
1315

1416
try:
1517
from contextlib import ExitStack
@@ -20,15 +22,19 @@
2022
class TestZip(unittest.TestCase):
2123
root = 'importlib_metadata.tests.data'
2224

25+
def _fixture_on_path(self, filename):
26+
pkg_file = resources.files(self.root).joinpath(filename)
27+
file = self.resources.enter_context(resources.as_file(pkg_file))
28+
assert file.name.startswith('example-'), file.name
29+
sys.path.insert(0, str(file))
30+
self.resources.callback(sys.path.pop, 0)
31+
2332
def setUp(self):
2433
# Find the path to the example-*.whl so we can add it to the front of
2534
# sys.path, where we'll then try to find the metadata thereof.
2635
self.resources = ExitStack()
2736
self.addCleanup(self.resources.close)
28-
wheel = self.resources.enter_context(
29-
path(self.root, 'example-21.12-py3-none-any.whl'))
30-
sys.path.insert(0, str(wheel))
31-
self.resources.callback(sys.path.pop, 0)
37+
self._fixture_on_path('example-21.12-py3-none-any.whl')
3238

3339
def test_zip_version(self):
3440
self.assertEqual(version('example'), '21.12')
@@ -66,10 +72,7 @@ def setUp(self):
6672
# sys.path, where we'll then try to find the metadata thereof.
6773
self.resources = ExitStack()
6874
self.addCleanup(self.resources.close)
69-
egg = self.resources.enter_context(
70-
path(self.root, 'example-21.12-py3.6.egg'))
71-
sys.path.insert(0, str(egg))
72-
self.resources.callback(sys.path.pop, 0)
75+
self._fixture_on_path('example-21.12-py3.6.egg')
7376

7477
def test_files(self):
7578
for file in files('example'):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ universal=1
5353

5454
[options.extras_require]
5555
testing =
56-
importlib_resources; python_version < "3.7"
56+
importlib_resources>=1.3; python_version < "3.9"
5757
packaging
5858
docs =
5959
sphinx

0 commit comments

Comments
 (0)