26
26
import control .tests .statefbk_test as statefbk_test
27
27
import control .tests .stochsys_test as stochsys_test
28
28
import control .tests .trdata_test as trdata_test
29
+ import control .tests .timeplot_test as timeplot_test
29
30
30
31
@pytest .mark .parametrize ("module, prefix" , [
31
32
(control , "" ), (control .flatsys , "flatsys." ), (control .optimal , "optimal." )
@@ -74,7 +75,8 @@ def test_kwarg_search(module, prefix):
74
75
# @parametrize messes up the check, but we know it is there
75
76
pass
76
77
77
- elif source and source .find ('unrecognized keyword' ) < 0 :
78
+ elif source and source .find ('unrecognized keyword' ) < 0 and \
79
+ source .find ('unexpected keyword' ) < 0 :
78
80
warnings .warn (
79
81
f"'unrecognized keyword' not found in unit test "
80
82
f"for { name } " )
@@ -161,7 +163,21 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
161
163
function (* args , ** kwargs , unknown = None )
162
164
163
165
166
+ @pytest .mark .parametrize (
167
+ "function" , [control .time_response_plot , control .TimeResponseData .plot ])
168
+ def test_time_response_plot_kwargs (function ):
169
+ # Create a system for testing
170
+ response = control .step_response (control .rss (4 , 2 , 2 ))
171
+
172
+ # Call the plotting function normally and make sure it works
173
+ function (response )
164
174
175
+ # Now add an unrecognized keyword and make sure there is an error
176
+ with pytest .raises (AttributeError ,
177
+ match = "(has no property|unexpected keyword)" ):
178
+ function (response , unknown = None )
179
+
180
+
165
181
#
166
182
# List of all unit tests that check for unrecognized keywords
167
183
#
@@ -185,6 +201,7 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
185
201
'gangof4_plot' : test_matplotlib_kwargs ,
186
202
'input_output_response' : test_unrecognized_kwargs ,
187
203
'interconnect' : interconnect_test .test_interconnect_exceptions ,
204
+ 'time_response_plot' : timeplot_test .test_errors ,
188
205
'linearize' : test_unrecognized_kwargs ,
189
206
'lqe' : test_unrecognized_kwargs ,
190
207
'lqr' : test_unrecognized_kwargs ,
@@ -230,6 +247,7 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
230
247
'StateSpace.__init__' : test_unrecognized_kwargs ,
231
248
'StateSpace.sample' : test_unrecognized_kwargs ,
232
249
'TimeResponseData.__call__' : trdata_test .test_response_copy ,
250
+ 'TimeResponseData.plot' : timeplot_test .test_errors ,
233
251
'TransferFunction.__init__' : test_unrecognized_kwargs ,
234
252
'TransferFunction.sample' : test_unrecognized_kwargs ,
235
253
'optimal.OptimalControlProblem.__init__' :
0 commit comments