From 5ee10187067cd0a6f6db2a3795db1deb62a88fce Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 21 Jun 2019 09:04:22 -0500 Subject: [PATCH 1/2] TST: More isolation for required dep test Setting PYTHONPATH to include a dir with these libs breaks the test. We use -E to disable that. Closes https://github.com/pandas-dev/pandas/issues/26983 --- pandas/tests/test_downstream.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index 9fe8b0f9563ef..9be107f9cd6f5 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -135,8 +135,23 @@ def test_pyarrow(df): def test_missing_required_dependency(): # GH 23868 - # use the -S flag to disable site-packages - call = ['python', '-S', '-c', 'import pandas'] + # To ensure proper isolation, we pass these flags + # -S : disable site-packages + # -s : disable user site-packages + # -E : disable PYTHON* env vars, especially PYTHONPATH + # And, that's apparently not enough, so we give up. + # https://github.com/MacPython/pandas-wheels/pull/50 + try: + subprocess.check_output(['python', '-sSE', '-c', 'import numpy'], + stderr=subprocess.DEVNULL) + except subprocess.CalledProcessError: + # NumPy is not around, we can do the test + pass + else: + # NumPy is in the isolation environment, give up. + pytest.skip("Required dependencies in isolated environment.") + + call = ['python', '-sSE', '-c', 'import pandas'] with pytest.raises(subprocess.CalledProcessError) as exc: subprocess.check_output(call, stderr=subprocess.STDOUT) From 2961aa2edbf45abb8b02f49c2a7bd9b962ffd517 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 21 Jun 2019 14:54:25 -0500 Subject: [PATCH 2/2] give up --- pandas/tests/test_downstream.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index 9be107f9cd6f5..bb662e99664e2 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -133,6 +133,7 @@ def test_pyarrow(df): tm.assert_frame_equal(result, df) +@pytest.mark.xfail(reason="pandas-wheels-50", strict=False) def test_missing_required_dependency(): # GH 23868 # To ensure proper isolation, we pass these flags @@ -141,20 +142,11 @@ def test_missing_required_dependency(): # -E : disable PYTHON* env vars, especially PYTHONPATH # And, that's apparently not enough, so we give up. # https://github.com/MacPython/pandas-wheels/pull/50 - try: - subprocess.check_output(['python', '-sSE', '-c', 'import numpy'], - stderr=subprocess.DEVNULL) - except subprocess.CalledProcessError: - # NumPy is not around, we can do the test - pass - else: - # NumPy is in the isolation environment, give up. - pytest.skip("Required dependencies in isolated environment.") - call = ['python', '-sSE', '-c', 'import pandas'] with pytest.raises(subprocess.CalledProcessError) as exc: subprocess.check_output(call, stderr=subprocess.STDOUT) output = exc.value.stdout.decode() - assert all(x in output for x in ['numpy', 'pytz', 'dateutil']) + for name in ['numpy', 'pytz', 'dateutil']: + assert name in output