Skip to content

Commit c7aabcc

Browse files
authored
Merge pull request #13444 from pytest-dev/skip-pkg-resources
testing: skip `pkg_resources` tests if modern setuptools
2 parents 83536b4 + 0010bfa commit c7aabcc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

testing/acceptance_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import sys
1111
import types
1212

13+
import setuptools
14+
1315
from _pytest.config import ExitCode
1416
from _pytest.pathlib import symlink_or_skip
1517
from _pytest.pytester import Pytester
@@ -722,10 +724,14 @@ def test_cmdline_python_package(self, pytester: Pytester, monkeypatch) -> None:
722724
assert result.ret != 0
723725
result.stderr.fnmatch_lines(["*not*found*test_missing*"])
724726

725-
def test_cmdline_python_namespace_package(
727+
@pytest.mark.skipif(
728+
int(setuptools.__version__.split(".")[0]) >= 80,
729+
reason="modern setuptools removing pkg_resources",
730+
)
731+
def test_cmdline_python_legacy_namespace_package(
726732
self, pytester: Pytester, monkeypatch
727733
) -> None:
728-
"""Test --pyargs option with namespace packages (#1567).
734+
"""Test --pyargs option with legacy namespace packages (#1567).
729735
730736
Ref: https://packaging.python.org/guides/packaging-namespace-packages/
731737
"""

testing/test_monkeypatch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import sys
99
import textwrap
1010

11+
import setuptools
12+
1113
from _pytest.monkeypatch import MonkeyPatch
1214
from _pytest.pytester import Pytester
1315
import pytest
@@ -429,6 +431,10 @@ class A:
429431

430432

431433
@pytest.mark.filterwarnings(r"ignore:.*\bpkg_resources\b:DeprecationWarning")
434+
@pytest.mark.skipif(
435+
int(setuptools.__version__.split(".")[0]) >= 80,
436+
reason="modern setuptools removing pkg_resources",
437+
)
432438
def test_syspath_prepend_with_namespace_packages(
433439
pytester: Pytester, monkeypatch: MonkeyPatch
434440
) -> None:

0 commit comments

Comments
 (0)