Skip to content

Commit 76775cb

Browse files
Merge pull request #430 from robbievanleeuwen/fix-plotting-tests
Only run plotting tests on linux
2 parents 90aef63 + c8f0b79 commit 76775cb

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

tests/geometry/test_geometry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import json
6+
import platform
67
import sys
78
from pathlib import Path
89

@@ -786,6 +787,7 @@ def test_split_section(unit_square):
786787
unit_square.split_section(point_i)
787788

788789

790+
@pytest.mark.skipif(platform.system() != "Linux", reason="Only test plotting on Linux")
789791
def test_plot_geometry(small_square_with_hole):
790792
"""Tests plot geometry executes without errors."""
791793
geom = small_square_with_hole

tests/post/test_post.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
import platform
6+
57
import matplotlib.pyplot as plt
68
import pytest
79
import pytest_check as check
@@ -11,6 +13,11 @@
1113
from sectionproperties.pre.library import rectangular_section
1214

1315

16+
linux_only = pytest.mark.skipif(
17+
platform.system() != "Linux", reason="Only test plotting on Linux"
18+
)
19+
20+
1421
@pytest.fixture
1522
def example_section() -> Section:
1623
"""Creates an example section with geometric properties.
@@ -51,6 +58,7 @@ def test_centroidal_properties_error(example_section):
5158
)
5259

5360

61+
@linux_only
5462
def test_save_plot(example_section, tmp_path):
5563
"""Tests saving a plot."""
5664
sec = example_section
@@ -61,22 +69,24 @@ def test_save_plot(example_section, tmp_path):
6169
plt.close("all")
6270

6371

64-
# def test_supplied_axis(example_section):
65-
# """Tests supplying an axis to a plot."""
66-
# sec = example_section
67-
# _, ax = plt.subplots()
72+
@linux_only
73+
def test_supplied_axis(example_section):
74+
"""Tests supplying an axis to a plot."""
75+
sec = example_section
76+
_, ax = plt.subplots()
6877

69-
# sec.plot_mesh(ax=ax, render=False)
70-
# plt.close("all")
71-
# sec.plot_mesh(nrows=2, axis_index=1, render=False)
72-
# plt.close("all")
78+
sec.plot_mesh(ax=ax, render=False)
79+
plt.close("all")
80+
sec.plot_mesh(nrows=2, axis_index=1, render=False)
81+
plt.close("all")
7382

74-
# with pytest.raises(ValueError, match="is not compatible"):
75-
# sec.plot_mesh(nrows=2, ncols=2, axis_index=5, render=False)
83+
with pytest.raises(ValueError, match="is not compatible"):
84+
sec.plot_mesh(nrows=2, ncols=2, axis_index=5, render=False)
7685

77-
# plt.close("all")
86+
plt.close("all")
7887

7988

89+
@linux_only
8090
def test_plot_centroids(example_section):
8191
"""Tests plotting centroids."""
8292
sec = example_section

tests/post/test_stress_post.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
from __future__ import annotations
44

5+
import platform
6+
57
import pytest
68

79
from sectionproperties.analysis import Section
810
from sectionproperties.pre import Material
911
from sectionproperties.pre.library import rectangular_section
1012

1113

14+
linux_only = pytest.mark.skipif(
15+
platform.system() != "Linux", reason="Only test plotting on Linux"
16+
)
17+
18+
1219
@pytest.fixture
1320
def example_section() -> tuple[Section, Material]:
1421
"""Creates an example section with geometric properties.
@@ -26,6 +33,7 @@ def example_section() -> tuple[Section, Material]:
2633
return Section(geometry=geom), mat_b
2734

2835

36+
@linux_only
2937
def test_stress_plot(example_section):
3038
"""Tests the plot_stress() method."""
3139
sec, mat_b = example_section
@@ -36,6 +44,7 @@ def test_stress_plot(example_section):
3644
stress.plot_stress(stress="n_zz", material_list=[mat_b], render=False)
3745

3846

47+
@linux_only
3948
def test_stress_plot_constant():
4049
"""Tests the plot_stress() method with a constant stress."""
4150
geom = rectangular_section(d=1, b=1)
@@ -45,6 +54,7 @@ def test_stress_plot_constant():
4554
sec.calculate_stress(n=1).plot_stress(stress="n_zz", render=False)
4655

4756

57+
@linux_only
4858
def test_stress_vector_plot(example_section):
4959
"""Tests the plot_stress_vector() method."""
5060
sec, _ = example_section
@@ -53,6 +63,7 @@ def test_stress_vector_plot(example_section):
5363
sec.calculate_stress(mzz=1).plot_stress_vector(stress="zxy", render=False)
5464

5565

66+
@linux_only
5667
def test_plot_mohrs_circles(example_section):
5768
"""Tests the plot_mohrs_circles() method."""
5869
sec, _ = example_section

0 commit comments

Comments
 (0)