From 9693556f27ee77ac74c380943b9b8e5b926edcf1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:52:49 +0000 Subject: [PATCH] [7.2.x] Fix test_cmdline_python_namespace_package (#10789) Co-authored-by: Bruno Oliveira --- testing/acceptance_test.py | 9 ++++++++- testing/test_monkeypatch.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index c7139b538b2..73d0cc785c2 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -694,7 +694,14 @@ def test_cmdline_python_namespace_package( # mixed module and filenames: monkeypatch.chdir("world") - result = pytester.runpytest("--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world") + + # pgk_resources.declare_namespace has been deprecated in favor of implicit namespace packages. + # While we could change the test to use implicit namespace packages, seems better + # to still ensure the old declaration via declare_namespace still works. + ignore_w = r"-Wignore:Deprecated call to `pkg_resources.declare_namespace" + result = pytester.runpytest( + "--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world", ignore_w + ) assert result.ret == 0 result.stdout.fnmatch_lines( [ diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 49635f95e79..b46ec05bbd2 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -425,6 +425,9 @@ class A: assert A.x == 1 +@pytest.mark.filterwarnings( + "ignore:Deprecated call to `pkg_resources.declare_namespace" +) def test_syspath_prepend_with_namespace_packages( pytester: Pytester, monkeypatch: MonkeyPatch ) -> None: