Skip to content

Commit

Permalink
Replace importlib_metadata with importlib.metadata on Python 3.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Jul 4, 2019
1 parent 4f9bf02 commit 15962e3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelog/5537.bugfix.rst
@@ -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
Expand Up @@ -11,7 +11,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
Expand Up @@ -26,6 +26,12 @@
)


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
Expand Up @@ -9,7 +9,6 @@
import warnings
from functools import lru_cache

import importlib_metadata
import py
from packaging.version import Version
from pluggy import HookimplMarker
Expand All @@ -25,6 +24,7 @@
from .findpaths import exists
from _pytest._code import ExceptionInfo
from _pytest._code import filter_traceback
from _pytest.compat import importlib_metadata
from _pytest.outcomes import fail
from _pytest.outcomes import Skipped
from _pytest.warning_types import PytestConfigWarning
Expand Down
2 changes: 1 addition & 1 deletion testing/acceptance_test.py
Expand Up @@ -4,10 +4,10 @@
import types

import attr
import importlib_metadata
import py

import pytest
from _pytest.compat import importlib_metadata
from _pytest.main import ExitCode
from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG

Expand Down
3 changes: 2 additions & 1 deletion testing/test_assertion.py
Expand Up @@ -172,7 +172,8 @@ def check(values, value):
return check
""",
"mainwrapper.py": """\
import pytest, importlib_metadata
import pytest, sys
from _pytest.compat import importlib_metadata
class DummyEntryPoint(object):
name = 'spam'
Expand Down
3 changes: 1 addition & 2 deletions testing/test_config.py
@@ -1,10 +1,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
@@ -1,4 +1,4 @@
import importlib_metadata
from _pytest.compat import importlib_metadata


def test_pytest_entry_points_are_identical():
Expand Down

0 comments on commit 15962e3

Please sign in to comment.