From afe9721b23b03f7d2ae41d1e9370e256b4458ced Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Tue, 27 Oct 2020 12:49:44 +0000 Subject: [PATCH] Backport PR #37428: Failing test_missing_required_dependency in pandas-wheels --- pandas/tests/test_downstream.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index b32c5e91af295..4113ff6bb27d3 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -150,6 +150,18 @@ def test_missing_required_dependency(): # https://github.com/MacPython/pandas-wheels/pull/50 pyexe = sys.executable.replace("\\", "/") + + # We skip this test if pandas is installed as a site package. We first + # import the package normally and check the path to the module before + # executing the test which imports pandas with site packages disabled. + call = [pyexe, "-c", "import pandas;print(pandas.__file__)"] + output = subprocess.check_output(call).decode() + if "site-packages" in output: + pytest.skip("pandas installed as site package") + + # This test will fail if pandas is installed as a site package. The flags + # prevent pandas being imported and the test will report Failed: DID NOT + # RAISE call = [pyexe, "-sSE", "-c", "import pandas"] msg = (