8000 rerun matplotlib tests on failures · python-control/python-control@5336c65 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5336c65

Browse files
committed
rerun matplotlib tests on failures
1 parent 192e5d1 commit 5336c65

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

control/tests/conftest.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"""conftest.py - pytest local plugins and fixtures"""
22

33
import os
4-
import sys
54
from contextlib import contextmanager
65

76
import matplotlib as mpl
87
import numpy as np
98
import pytest
10-
import scipy as sp
119

1210
import control
1311

@@ -45,15 +43,15 @@ def control_defaults():
4543
params=[pytest.param("arrayout", marks=matrixerrorfilter),
4644
pytest.param("matrixout", marks=matrixfilter)])
4745
def matarrayout(request):
48-
"""Switch the config to use np.ndarray and np.matrix as returns"""
46+
"""Switch the config to use np.ndarray and np.matrix as returns."""
4947
restore = control.config.defaults['statesp.use_numpy_matrix']
5048
control.use_numpy_matrix(request.param == "matrixout", warn=False)
5149
yield
5250
control.use_numpy_matrix(restore, warn=False)
5351

5452

5553
def ismatarrayout(obj):
56-
"""Test if the returned object has the correct type as configured
54+
"""Test if the returned object has the correct type as configured.
5755
5856
note that isinstance(np.matrix(obj), np.ndarray) is True
5957
"""
@@ -63,15 +61,15 @@ def ismatarrayout(obj):
6361

6462

6563
def asmatarrayout(obj):
66-
"""Return a object according to the configured default"""
64+
"""Return a object according to the configured default."""
6765
use_matrix = control.config.defaults['statesp.use_numpy_matrix']
6866
matarray = np.asmatrix if use_matrix else np.asarray
6967
return matarray(obj)
7068

7169

7270
@contextmanager
7371
def check_deprecated_matrix():
74-
"""Check that a call produces a deprecation warning because of np.matrix"""
72+
"""Check that a call produces a deprecation warning because of np.matrix."""
7573
use_matrix = control.config.defaults['statesp.use_numpy_matrix']
7674
if use_matrix:
7775
with pytest.deprecated_call():
@@ -94,19 +92,20 @@ def check_deprecated_matrix():
9492
False)]
9593
if usebydefault or TEST_MATRIX_AND_ARRAY])
9694
def matarrayin(request):
97-
"""Use array and matrix to construct input data in tests"""
95+
"""Use array and matrix to construct input data in tests."""
9896
return request.param
9997

10098

10199
@pytest.fixture(scope="function")
102100
def editsdefaults():
103-
"""Make sure any changes to the defaults only last during a test"""
101+
"""Make sure any changes to the defaults only last during a test."""
104102
restore = control.config.defaults.copy()
105103
yield
106104
control.config.defaults = restore.copy()
107105

108106

109107
@pytest.fixture(scope="function")
108+
@pytest.mark.flaky(reruns=2, reruns_delay=1)
110109
def mplcleanup():
111110
"""Clean up any plots and changes a test may have made to matplotlib.
112111

0 commit comments

Comments
 (0)
0