Skip to content

Commit df0c33c

Browse files
committed
test(github): win32 tests against command not found instead
1 parent 4329d25 commit df0c33c

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

tests/test_concat.py

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test the `concat` module."""
22

33
import pathlib
4+
from sys import platform
45

56
import matplotlib as mpl
67
import matplotlib.pyplot as plt
@@ -45,41 +46,57 @@ def test_help(capfd) -> None:
4546

4647
def test_combine(tmp_path: pathlib.Path) -> None:
4748
"""Test that the `combine` function works."""
48-
plot()
49-
plt.savefig(tmp_path / "test1.png")
50-
plot()
51-
plt.savefig(tmp_path / "test2.png")
52-
plot()
53-
plt.savefig(tmp_path / "test3.png")
54-
plot()
55-
plt.savefig(tmp_path / "test4.png")
56-
cosmoplots.combine(
57-
tmp_path / "test1.png",
58-
tmp_path / "test2.png",
59-
tmp_path / "test3.png",
60-
tmp_path / "test4.png",
61-
).in_grid(w=2, h=2).save(tmp_path / "out.png")
62-
first_img = tmp_path / "out.png"
63-
assert first_img.exists()
64-
6549

66-
def test_in_grid_not_specified(tmp_path: pathlib.Path) -> None:
67-
"""Test error when `in_grid` has not been called."""
68-
plot()
69-
plt.savefig(tmp_path / "test1.png")
70-
plot()
71-
plt.savefig(tmp_path / "test2.png")
72-
plot()
73-
plt.savefig(tmp_path / "test3.png")
74-
plot()
75-
plt.savefig(tmp_path / "test4.png")
76-
with pytest.raises(ValueError):
50+
def _combine() -> None:
51+
plot()
52+
plt.savefig(tmp_path / "test1.png")
53+
plot()
54+
plt.savefig(tmp_path / "test2.png")
55+
plot()
56+
plt.savefig(tmp_path / "test3.png")
57+
plot()
58+
plt.savefig(tmp_path / "test4.png")
7759
cosmoplots.combine(
7860
tmp_path / "test1.png",
7961
tmp_path / "test2.png",
8062
tmp_path / "test3.png",
8163
tmp_path / "test4.png",
82-
).save(tmp_path / "out.png")
64+
).in_grid(w=2, h=2).save(tmp_path / "out.png")
65+
66+
if platform == "win32":
67+
with pytest.raises(ChildProcessError):
68+
_combine()
69+
else:
70+
_combine()
71+
first_img = tmp_path / "out.png"
72+
assert first_img.exists()
73+
74+
75+
def test_in_grid_not_specified(tmp_path: pathlib.Path) -> None:
76+
"""Test error when `in_grid` has not been called."""
77+
78+
def _grid() -> None:
79+
plot()
80+
plt.savefig(tmp_path / "test1.png")
81+
plot()
82+
plt.savefig(tmp_path / "test2.png")
83+
plot()
84+
plt.savefig(tmp_path / "test3.png")
85+
plot()
86+
plt.savefig(tmp_path / "test4.png")
87+
with pytest.raises(ValueError):
88+
cosmoplots.combine(
89+
tmp_path / "test1.png",
90+
tmp_path / "test2.png",
91+
tmp_path / "test3.png",
92+
tmp_path / "test4.png",
93+
).save(tmp_path / "out.png")
94+
95+
if platform == "win32":
96+
with pytest.raises(ChildProcessError):
97+
_grid()
98+
else:
99+
_grid()
83100

84101

85102
def test_output_not_found(tmp_path: pathlib.Path) -> None:

0 commit comments

Comments
 (0)