Skip to content

Commit

Permalink
see if this patch fixes and if so then move this to a follow up PR
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfeickert committed Aug 10, 2023
1 parent b8faaa6 commit 505753b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/contrib/test_viz.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import sys
from unittest.mock import patch

import matplotlib
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -181,3 +182,25 @@ def test_plot_results_components_data_structure(datadir):
brazil.plot_results(
data["testmus"], data["results"], test_size=0.05, ax=ax, components=True
)


def test_plot_results_wrong_axis_labels(datadir):
"""
If the returned labels are different from the expected, then the hardcoded
values in label_part will be wrong, causing `next` to fail on the iterator
for label_idx.
"""
data = json.load(datadir.joinpath("hypotest_results.json").open(encoding="utf-8"))

fig = Figure()
ax = fig.subplots()

with patch(
"matplotlib.axes._axes.Axes.get_legend_handles_labels"
) as mock_get_legend_handles_labels:
mock_get_legend_handles_labels.return_value = None, ["fail"]

with pytest.raises(StopIteration):
brazil.plot_results(data["testmus"], data["results"], test_size=0.05, ax=ax)

mock_get_legend_handles_labels.assert_called()

0 comments on commit 505753b

Please sign in to comment.