Skip to content

Commit 557e56f

Browse files
committed
TST: fix sub process usage on windows
thanks to @story645 for sorting this out
1 parent fd9f102 commit 557e56f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import subprocess
2+
import os
23
import sys
34
import pytest
45

@@ -7,16 +8,21 @@
78
def test_webagg_fallback(backend):
89
if backend == "nbagg":
910
pytest.importorskip("IPython")
11+
env = {}
12+
if os.name == "nt":
13+
env = dict(os.environ)
14+
else:
15+
env = {"DISPLAY": ""}
16+
17+
env["MPLBACKEND"] = backend
18+
1019
test_code = (
1120
"import os;"
12-
+ f"os.environ['MPLBACKEND'] = '{backend}';"
21+
+ f"assert os.environ['MPLBACKEND'] == '{backend}';"
1322
+ "import matplotlib.pyplot as plt; "
1423
+ "print(plt.get_backend());"
1524
f"assert '{backend}' == plt.get_backend().lower();"
1625
)
17-
ret = subprocess.call(
18-
[sys.executable, "-c", test_code],
19-
env={"MPLBACKEND": backend, "DISPLAY": ""}
20-
)
26+
ret = subprocess.call([sys.executable, "-c", test_code], env=env)
2127

2228
assert ret == 0

0 commit comments

Comments
 (0)