From 3c5bcbe5ca9b1e30357102318fd8c0abc1268af7 Mon Sep 17 00:00:00 2001 From: bartzbeielstein <32470350+bartzbeielstein@users.noreply.github.com> Date: Wed, 10 Jun 2026 18:39:40 +0200 Subject: [PATCH] test(tricands): close leaked figures before each test test_visualization_2d mocks plt.figure, so tricands draws into whatever Axes gca() finds. Under pytest-xdist a 3D Axes leaked by an earlier test on the same worker makes scatter raise 's must be a scalar, or float array-like with the same size as x and y' (seen on CI run 27290133117). Close all figures in setup_method so the test owns its pyplot state. Co-Authored-By: Claude Fable 5 --- tests/test_tricands.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_tricands.py b/tests/test_tricands.py index e94c462b..8e2d8f7f 100644 --- a/tests/test_tricands.py +++ b/tests/test_tricands.py @@ -17,6 +17,13 @@ class TestTricands: """Test suite for tricands module.""" def setup_method(self): + # Close figures leaked by earlier tests on the same xdist worker: + # test_visualization_2d mocks plt.figure, so tricands draws into + # whatever Axes gca() finds — a leaked 3D Axes makes scatter fail + # with "s must be a scalar, or float array-like ...". + import matplotlib.pyplot as plt + + plt.close("all") # Create invalid (too few points) X self.X_small = np.array([[0.1, 0.1]]) # Create valid 2D X