Replace importlib_metadata with importlib.metadata on Python 3.… (#5539)
Replace importlib_metadata with importlib.metadata on Python 3.8+
This commit is contained in:
commit
60a358fa2d
|
@ -0,0 +1 @@
|
||||||
|
Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
|
|
@ -0,0 +1,2 @@
|
||||||
|
Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
|
||||||
|
standard library on Python 3.8+.
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ INSTALL_REQUIRES = [
|
||||||
'pathlib2>=2.2.0;python_version<"3.6"',
|
'pathlib2>=2.2.0;python_version<"3.6"',
|
||||||
'colorama;sys_platform=="win32"',
|
'colorama;sys_platform=="win32"',
|
||||||
"pluggy>=0.12,<1.0",
|
"pluggy>=0.12,<1.0",
|
||||||
"importlib-metadata>=0.12",
|
'importlib-metadata>=0.12;python_version<"3.8"',
|
||||||
"wcwidth",
|
"wcwidth",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,12 @@ MODULE_NOT_FOUND_ERROR = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 8):
|
||||||
|
from importlib import metadata as importlib_metadata # noqa
|
||||||
|
else:
|
||||||
|
import importlib_metadata # noqa
|
||||||
|
|
||||||
|
|
||||||
def _format_args(func):
|
def _format_args(func):
|
||||||
return str(signature(func))
|
return str(signature(func))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import types
|
||||||
import warnings
|
import warnings
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
import importlib_metadata
|
|
||||||
import py
|
import py
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
from pluggy import HookimplMarker
|
from pluggy import HookimplMarker
|
||||||
|
@ -25,6 +24,7 @@ from .findpaths import determine_setup
|
||||||
from .findpaths import exists
|
from .findpaths import exists
|
||||||
from _pytest._code import ExceptionInfo
|
from _pytest._code import ExceptionInfo
|
||||||
from _pytest._code import filter_traceback
|
from _pytest._code import filter_traceback
|
||||||
|
from _pytest.compat import importlib_metadata
|
||||||
from _pytest.outcomes import fail
|
from _pytest.outcomes import fail
|
||||||
from _pytest.outcomes import Skipped
|
from _pytest.outcomes import Skipped
|
||||||
from _pytest.warning_types import PytestConfigWarning
|
from _pytest.warning_types import PytestConfigWarning
|
||||||
|
|
|
@ -358,7 +358,7 @@ class MyOptionParser(argparse.ArgumentParser):
|
||||||
getattr(args, FILE_OR_DIR).extend(argv)
|
getattr(args, FILE_OR_DIR).extend(argv)
|
||||||
return args
|
return args
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 8): # pragma: no cover
|
if sys.version_info[:2] < (3, 9): # pragma: no cover
|
||||||
# Backport of https://github.com/python/cpython/pull/14316 so we can
|
# Backport of https://github.com/python/cpython/pull/14316 so we can
|
||||||
# disable long --argument abbreviations without breaking short flags.
|
# disable long --argument abbreviations without breaking short flags.
|
||||||
def _parse_optional(self, arg_string):
|
def _parse_optional(self, arg_string):
|
||||||
|
|
|
@ -4,10 +4,10 @@ import textwrap
|
||||||
import types
|
import types
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import importlib_metadata
|
|
||||||
import py
|
import py
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from _pytest.compat import importlib_metadata
|
||||||
from _pytest.main import ExitCode
|
from _pytest.main import ExitCode
|
||||||
from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG
|
from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,8 @@ class TestImportHookInstallation:
|
||||||
return check
|
return check
|
||||||
""",
|
""",
|
||||||
"mainwrapper.py": """\
|
"mainwrapper.py": """\
|
||||||
import pytest, importlib_metadata
|
import pytest
|
||||||
|
from _pytest.compat import importlib_metadata
|
||||||
|
|
||||||
class DummyEntryPoint(object):
|
class DummyEntryPoint(object):
|
||||||
name = 'spam'
|
name = 'spam'
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import importlib_metadata
|
|
||||||
|
|
||||||
import _pytest._code
|
import _pytest._code
|
||||||
import pytest
|
import pytest
|
||||||
|
from _pytest.compat import importlib_metadata
|
||||||
from _pytest.config import _iter_rewritable_modules
|
from _pytest.config import _iter_rewritable_modules
|
||||||
from _pytest.config.exceptions import UsageError
|
from _pytest.config.exceptions import UsageError
|
||||||
from _pytest.config.findpaths import determine_setup
|
from _pytest.config.findpaths import determine_setup
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import importlib_metadata
|
from _pytest.compat import importlib_metadata
|
||||||
|
|
||||||
|
|
||||||
def test_pytest_entry_points_are_identical():
|
def test_pytest_entry_points_are_identical():
|
||||||
|
|
Loading…
Reference in New Issue