Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.6] Replace importlib_metadata with importlib.metadata on Python 3.8+ (#5539) #5945

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/5523.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
2 changes: 2 additions & 0 deletions changelog/5537.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
standard library on Python 3.8+.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'pathlib2>=2.2.0;python_version<"3.6"',
'colorama;sys_platform=="win32"',
"pluggy>=0.12,<1.0",
"importlib-metadata>=0.12",
'importlib-metadata>=0.12;python_version<"3.8"',
"wcwidth",
]

Expand Down
6 changes: 6 additions & 0 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def spec_from_file_location(*_, **__):
return None


if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata # noqa
else:
import importlib_metadata # noqa


def _format_args(func):
return str(signature(func))

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import types
import warnings

import importlib_metadata
import py
import six
from packaging.version import Version
Expand All @@ -31,6 +30,7 @@
from _pytest import deprecated
from _pytest._code import ExceptionInfo
from _pytest._code import filter_traceback
from _pytest.compat import importlib_metadata
from _pytest.compat import lru_cache
from _pytest.compat import safe_str
from _pytest.outcomes import fail
Expand Down
2 changes: 1 addition & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import types

import attr
import importlib_metadata
import py
import six

import pytest
from _pytest.compat import importlib_metadata
from _pytest.main import EXIT_NOTESTSCOLLECTED
from _pytest.main import EXIT_USAGEERROR
from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG
Expand Down
3 changes: 2 additions & 1 deletion testing/test_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def check(values, value):
return check
""",
"mainwrapper.py": """\
import pytest, importlib_metadata
import pytest
from _pytest.compat import importlib_metadata

class DummyEntryPoint(object):
name = 'spam'
Expand Down
3 changes: 1 addition & 2 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import sys
import textwrap

import importlib_metadata

import _pytest._code
import pytest
from _pytest.compat import importlib_metadata
from _pytest.config import _iter_rewritable_modules
from _pytest.config.exceptions import UsageError
from _pytest.config.findpaths import determine_setup
Expand Down
2 changes: 1 addition & 1 deletion testing/test_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import division
from __future__ import print_function

import importlib_metadata
from _pytest.compat import importlib_metadata


def test_pytest_entry_points_are_identical():
Expand Down