Skip to content

Commit 359f58e

Browse files
committed
Refactor mock_matplotlib fixture in tests/conftest.py for improved compatibility for python 3.9 and lower
1 parent aeb3742 commit 359f58e

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

tests/conftest.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,19 @@ def mock_geopandas():
8888
@pytest.fixture
8989
def mock_matplotlib():
9090
"""Mock matplotlib functionality for chart testing"""
91-
with (
92-
mock.patch("matplotlib.pyplot.subplots") as mock_subplots,
93-
mock.patch("matplotlib.pyplot.bar") as mock_bar,
94-
mock.patch("matplotlib.pyplot.pie") as mock_pie,
95-
):
96-
mock_fig, mock_ax = mock.Mock(), mock.Mock()
97-
mock_subplots.return_value = (mock_fig, mock_ax)
98-
99-
yield {
100-
"subplots": mock_subplots,
101-
"bar": mock_bar,
102-
"pie": mock_pie,
103-
"fig": mock_fig,
104-
"ax": mock_ax,
105-
}
91+
with mock.patch("matplotlib.pyplot.subplots") as mock_subplots:
92+
with mock.patch("matplotlib.pyplot.bar") as mock_bar:
93+
with mock.patch("matplotlib.pyplot.pie") as mock_pie:
94+
mock_fig, mock_ax = mock.Mock(), mock.Mock()
95+
mock_subplots.return_value = (mock_fig, mock_ax)
96+
97+
yield {
98+
"subplots": mock_subplots,
99+
"bar": mock_bar,
100+
"pie": mock_pie,
101+
"fig": mock_fig,
102+
"ax": mock_ax,
103+
}
106104

107105

108106
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)