Skip to content

Commit 5ee1018

Browse files
committed
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 pandas-dev#26983
1 parent 171615a commit 5ee1018

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pandas/tests/test_downstream.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,23 @@ def test_pyarrow(df):
135135

136136
def test_missing_required_dependency():
137137
# GH 23868
138-
# use the -S flag to disable site-packages
139-
call = ['python', '-S', '-c', 'import pandas']
138+
# To ensure proper isolation, we pass these flags
139+
# -S : disable site-packages
140+
# -s : disable user site-packages
141+
# -E : disable PYTHON* env vars, especially PYTHONPATH
142+
# And, that's apparently not enough, so we give up.
143+
# https://github.com/MacPython/pandas-wheels/pull/50
144+
try:
145+
subprocess.check_output(['python', '-sSE', '-c', 'import numpy'],
146+
stderr=subprocess.DEVNULL)
147+
except subprocess.CalledProcessError:
148+
# NumPy is not around, we can do the test
149+
pass
150+
else:
151+
# NumPy is in the isolation environment, give up.
152+
pytest.skip("Required dependencies in isolated environment.")
153+
154+
call = ['python', '-sSE', '-c', 'import pandas']
140155

141156
with pytest.raises(subprocess.CalledProcessError) as exc:
142157
subprocess.check_output(call, stderr=subprocess.STDOUT)

0 commit comments

Comments
 (0)