Skip to content

Commit 92d36cc

Browse files
committed
cleanup after plotting in test functions
1 parent ed8a1c1 commit 92d36cc

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

control/tests/timeplot_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import matplotlib.pyplot as plt
88
import numpy as np
99

10-
from control.tests.conftest import slycotonly
10+
from control.tests.conftest import slycotonly, mplcleanup
1111

1212
# Detailed test of (almost) all functionality
1313
#
@@ -67,6 +67,7 @@
6767
True, True, False, False, False, False),
6868
])
6969

70+
@pytest.mark.usefixtures('mplcleanup')
7071
def test_response_plots(
7172
fcn, sys, pltinp, pltout, cmbsig, cmbtrc,
7273
trpose, secsys, clear=True):
@@ -190,6 +191,7 @@ def test_response_plots(
190191
plt.clf()
191192

192193

194+
@pytest.mark.usefixtures('mplcleanup')
193195
def test_axes_setup():
194196
get_plot_axes = ct.get_plot_axes
195197

@@ -238,6 +240,7 @@ def test_axes_setup():
238240

239241

240242
@slycotonly
243+
@pytest.mark.usefixtures('mplcleanup')
241244
def test_legend_map():
242245
sys_mimo = ct.tf2ss(
243246
[[[1], [0.1]], [[0.2], [1]]],
@@ -250,6 +253,7 @@ def test_legend_map():
250253
title='MIMO step response with custom legend placement')
251254

252255

256+
@pytest.mark.usefixtures('mplcleanup')
253257
def test_combine_time_responses():
254258
sys_mimo = ct.rss(4, 2, 2)
255259
timepts = np.linspace(0, 10, 100)
@@ -316,6 +320,7 @@ def test_combine_time_responses():
316320
@pytest.mark.parametrize("resp_fcn", [
317321
ct.step_response, ct.initial_response, ct.impulse_response,
318322
ct.forced_response, ct.input_output_response])
323+
@pytest.mark.usefixtures('mplcleanup')
319324
def test_list_responses(resp_fcn):
320325
sys1 = ct.rss(2, 2, 2, strictly_proper=True)
321326
sys2 = ct.rss(2, 2, 2, strictly_proper=True)
@@ -362,6 +367,7 @@ def test_list_responses(resp_fcn):
362367

363368

364369
@slycotonly
370+
@pytest.mark.usefixtures('mplcleanup')
365371
def test_linestyles():
366372
# Check to make sure we can change line styles
367373
sys_mimo = ct.tf2ss(
@@ -391,6 +397,7 @@ def test_linestyles():
391397
assert lines[7].get_color() == 'green' and lines[7].get_linestyle() == '--'
392398

393399

400+
@pytest.mark.usefixtures('mplcleanup')
394401
def test_rcParams():
395402
sys = ct.rss(2, 2, 2)
396403

@@ -428,7 +435,7 @@ def test_rcParams():
428435
@pytest.mark.parametrize("resp_fcn", [
429436
ct.step_response, ct.initial_response, ct.impulse_response,
430437
ct.forced_response, ct.input_output_response])
431-
@pytest.mark.usefixtures("editsdefaults")
438+
@pytest.mark.usefixtures('editsdefaults', 'mplcleanup')
432439
def test_timeplot_trace_labels(resp_fcn):
433440
plt.close('all')
434441
sys1 = ct.rss(2, 2, 2, strictly_proper=True, name='sys1')
@@ -486,6 +493,7 @@ def test_timeplot_trace_labels(resp_fcn):
486493
plt.close()
487494

488495

496+
@pytest.mark.usefixtures('mplcleanup')
489497
def test_full_label_override():
490498
sys1 = ct.rss(2, 2, 2, strictly_proper=True, name='sys1')
491499
sys2 = ct.rss(2, 2, 2, strictly_proper=True, name='sys2')
@@ -531,6 +539,7 @@ def test_full_label_override():
531539
assert legend_text[i].get_text() == label
532540

533541

542+
@pytest.mark.usefixtures('mplcleanup')
534543
def test_relabel():
535544
sys1 = ct.rss(2, inputs='u', outputs='y')
536545
sys2 = ct.rss(1, 1, 1) # uses default i/o labels

0 commit comments

Comments
 (0)