Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b24bb4

Browse files
Switch to pytest and add optional Python 3.8 test (#380)
* switch Travis to use pytest instead of deprecated setup.py test* fix import error in discrete unit test (for pytest)* add optional Travis test against python3.8* remove unused (and sometimes incorrect) creation of test suites and run_all.pyCo-authored-by: bnavigator <code@bnavigator.de>
1 parent3b19ae9 commit6b24bb4

33 files changed

+21
-173
lines changed

‎.travis.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ env:
2828
-SCIPY=scipy SLYCOT=# default, w/out slycot
2929
-SCIPY="scipy==0.19.1" SLYCOT=# legacy support, w/out slycot
3030

31-
# Add optional builds that test against latest version of slycot
31+
# Add optional builds that test against latest version of slycot, python
3232
jobs:
3333
include:
3434
-name:"linux, Python 2.7, slycot=source"
@@ -43,8 +43,13 @@ jobs:
4343
services:xvfb
4444
python:"3.7"
4545
env:SCIPY=scipy SLYCOT=source
46+
-name:"linux, Python 3.8, slycot=source"
47+
os:linux
48+
dist:xenial
49+
services:xvfb
50+
python:"3.8"
51+
env:SCIPY=scipy SLYCOT=source
4652

47-
matrix:
4853
# Exclude combinations that are very unlikely (and don't work)
4954
exclude:
5055
-python:"3.7"# python3.7 should use latest scipy
@@ -63,6 +68,12 @@ matrix:
6368
services:xvfb
6469
python:"3.7"
6570
env:SCIPY=scipy SLYCOT=source
71+
-name:"linux, Python 3.8, slycot=source"
72+
os:linux
73+
dist:xenial
74+
services:xvfb
75+
python:"3.8"
76+
env:SCIPY=scipy SLYCOT=source
6677

6778
# install required system libraries
6879
before_install:
@@ -97,6 +108,7 @@ before_install:
97108
fi
98109
# Make sure to look in the right place for python libraries (for slycot)
99110
-export LIBRARY_PATH="$HOME/miniconda/envs/test-environment/lib"
111+
-conda install pytest
100112
# coveralls not in conda repos => install via pip instead
101113
-pip install coveralls
102114

@@ -118,7 +130,7 @@ install:
118130
# command to run tests
119131
script:
120132
-'if [ $SLYCOT != "" ]; then python -c "import slycot"; fi'
121-
-coverage runsetup.py test
133+
-coverage run-m pytest --disable-warnings control/tests
122134

123135
# only run examples if Slycot is install
124136
# set PYTHONPATH for examples

‎control/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,5 @@
7979
exceptImportError:
8080
__version__="dev"
8181

82-
# The following is to use Numpy's testing framework
83-
# Tests go under directory tests/, benchmarks under directory benchmarks/
84-
fromnumpy.testingimportTester
85-
test=Tester().test
86-
bench=Tester().bench
87-
8882
# Initialize default parameter values
8983
reset_defaults()

‎control/tests/bdalg_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
#
3-
# bdalg_test.py - testsuit for block diagram algebra
3+
# bdalg_test.py - testsuite for block diagram algebra
44
# RMM, 30 Mar 2011 (based on TestBDAlg from v0.4a)
55

66
importunittest
@@ -271,9 +271,5 @@ def test_feedback_args(self):
271271
self.assertTrue(isinstance(sys,ctrl.FRD))
272272

273273

274-
defsuite():
275-
returnunittest.TestLoader().loadTestsFromTestCase(TestFeedback)
276-
277-
278274
if__name__=="__main__":
279275
unittest.main()

‎control/tests/canonical_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ def test_similarity(self):
288288
np.testing.assert_array_almost_equal(mimo_new.C,mimo_ini.C)
289289
np.testing.assert_array_almost_equal(mimo_new.D,mimo_ini.D)
290290

291-
defsuite():
292-
returnunittest.TestLoader().loadTestsFromTestCase(TestFeedback)
293-
294291

295292
if__name__=="__main__":
296293
unittest.main()

‎control/tests/config_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ def tearDown(self):
218218
# Reset the configuration defaults
219219
ct.config.reset_defaults()
220220

221-
defsuite():
222-
returnunittest.TestLoader().loadTestsFromTestCase(TestTimeresp)
223-
224221

225222
if__name__=='__main__':
226223
unittest.main()

‎control/tests/convert_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ def test_tf2ss_robustness(self):
268268
np.testing.assert_array_almost_equal(np.sort(sys2tf.pole()),
269269
np.sort(sys2ss.pole()))
270270

271-
defsuite():
272-
returnunittest.TestLoader().loadTestsFromTestCase(TestConvert)
273271

274272
if__name__=="__main__":
275273
unittest.main()

‎control/tests/ctrlutil_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,5 @@ def test_mag2db_array(self):
5858
np.testing.assert_array_almost_equal(db_array,self.db)
5959

6060

61-
deftest_suite():
62-
returnunittest.TestLoader().loadTestsFromTestCase(TestUtils)
63-
6461
if__name__=="__main__":
6562
unittest.main()

‎control/tests/discrete_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
importunittest
77
importnumpyasnp
8-
fromcontrolimport*
8+
fromcontrolimportStateSpace,TransferFunction,feedback,step_response, \
9+
isdtime,timebase,isctime,sample_system,bode,impulse_response, \
10+
timebaseEqual,forced_response
911
fromcontrolimportmatlab
1012

1113
classTestDiscrete(unittest.TestCase):
@@ -382,9 +384,6 @@ def test_discrete_bode(self):
382384
np.testing.assert_array_almost_equal(mag_out,np.absolute(H_z))
383385
np.testing.assert_array_almost_equal(phase_out,np.angle(H_z))
384386

385-
defsuite():
386-
returnunittest.TestLoader().loadTestsFromTestCase(TestDiscrete)
387-
388387

389388
if__name__=="__main__":
390389
unittest.main()

‎control/tests/flatsys_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,5 @@ def tearDown(self):
127127
ct.reset_defaults()
128128

129129

130-
defsuite():
131-
returnunittest.TestLoader().loadTestsFromTestCase(TestFlatSys)
132-
133-
134130
if__name__=='__main__':
135131
unittest.main()

‎control/tests/frd_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,5 @@ def test_evalfr_deprecated(self):
415415
self.assertRaises(PendingDeprecationWarning,frd_tf.evalfr,1.)
416416

417417

418-
defsuite():
419-
returnunittest.TestLoader().loadTestsFromTestCase(TestFRD)
420-
421418
if__name__=="__main__":
422419
unittest.main()

‎control/tests/freqresp_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,5 @@ def test_options(self):
235235
ctrl.config.reset_defaults()
236236

237237

238-
defsuite():
239-
returnunittest.TestLoader().loadTestsFromTestCase(TestTimeresp)
240-
241238
if__name__=='__main__':
242239
unittest.main()

‎control/tests/iosys_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,6 @@ def test_duplicates(self):
911911
self.assertEqual(len(warnval),0)
912912

913913

914-
defsuite():
915-
returnunittest.TestLoader().loadTestsFromTestCase(TestTimeresp)
916-
917-
918914
# Predator prey dynamics
919915
defpredprey(t,x,u,params={}):
920916
r=params.get('r',2)

‎control/tests/lti_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def test_dcgain(self):
7070
np.testing.assert_equal(sys.dcgain(),42)
7171
np.testing.assert_equal(dcgain(sys),42)
7272

73-
defsuite():
74-
returnunittest.TestLoader().loadTestsFromTestCase(TestUtils)
7573

7674
if__name__=="__main__":
7775
unittest.main()

‎control/tests/margin_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
#
3-
# margin_test.py - testsuit for stability margin commands
3+
# margin_test.py - testsuite for stability margin commands
44
# RMM, 15 Jul 2011
55

66
from __future__importprint_function
@@ -310,8 +310,6 @@ def test_zmore_margin(self):
310310
assert_array_almost_equal(
311311
res,test['result'],test['digits'])
312312

313-
deftest_suite():
314-
returnunittest.TestLoader().loadTestsFromTestCase(TestMargin)
315313

316314
if__name__=="__main__":
317315
unittest.main()

‎control/tests/mateqn_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,5 @@ def test_raise(self):
299299
assert_raises(ControlArgument,cdare,A,B,Q,R,S)
300300

301301

302-
defsuite():
303-
returnunittest.TestLoader().loadTestsFromTestCase(TestMatrixEquations)
304-
305302
if__name__=="__main__":
306303
unittest.main()

‎control/tests/matlab_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,6 @@ def test_tf_string_args(self):
688688
# for i in range(len(tfdata)):
689689
# np.testing.assert_array_almost_equal(tfdata_1[i], tfdata_2[i])
690690

691-
deftest_suite():
692-
returnunittest.TestLoader().loadTestsFromTestCase(TestMatlab)
693691

694692
if__name__=='__main__':
695693
unittest.main()

‎control/tests/minreal_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ def testMinrealtf(self):
108108
np.testing.assert_array_almost_equal(hm.num[0][0],hr.num[0][0])
109109
np.testing.assert_array_almost_equal(hm.den[0][0],hr.den[0][0])
110110

111-
defsuite():
112-
returnunittest.TestLoader().loadTestsFromTestCase(TestMinreal)
113-
114111

115112
if__name__=="__main__":
116113
unittest.main()

‎control/tests/modelsimp_array_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ def tearDown(self):
169169
# Reset configuration variables to their original settings
170170
control.config.reset_defaults()
171171

172-
defsuite():
173-
returnunittest.TestLoader().loadTestsFromTestCase(TestModelsimp)
174-
175172

176173
if__name__=='__main__':
177174
unittest.main()

‎control/tests/modelsimp_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ def testBalredMatchDC(self):
130130
np.testing.assert_array_almost_equal(rsys.C,Crtrue,decimal=4)
131131
np.testing.assert_array_almost_equal(rsys.D,Drtrue,decimal=4)
132132

133-
defsuite():
134-
returnunittest.TestLoader().loadTestsFromTestCase(TestModelsimp)
135-
136133

137134
if__name__=='__main__':
138135
unittest.main()

‎control/tests/nichols_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def testNgrid(self):
2929
nichols(self.sys,grid=False)
3030
ngrid()
3131

32-
defsuite():
33-
returnunittest.TestLoader().loadTestsFromTestCase(TestStateSpace)
34-
3532

3633
if__name__=="__main__":
3734
unittest.main()

‎control/tests/phaseplot_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def invpend_ode(self, x, t, m=1., l=1., b=0, g=9.8):
7777
defoscillator_ode(self,x,t,m=1.,b=1,k=1,extra=None):
7878
return (x[1],-k/m*x[0]-b/m*x[1])
7979

80-
defsuite():
81-
returnunittest.TestLoader().loadTestsFromTestCase(TestPhasePlot)
8280

8381
if__name__=='__main__':
8482
unittest.main()

‎control/tests/rlocus_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def test_root_locus_zoom(self):
6868
assert_array_almost_equal(zoom_x,zoom_x_valid)
6969
assert_array_almost_equal(zoom_y,zoom_y_valid)
7070

71-
deftest_suite():
72-
returnunittest.TestLoader().loadTestsFromTestCase(TestRootLocus)
7371

7472
if__name__=="__main__":
7573
unittest.main()

‎control/tests/robust_array_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,5 +388,6 @@ def testSiso(self):
388388
deftearDown(self):
389389
control.config.reset_defaults()
390390

391+
391392
if__name__=="__main__":
392393
unittest.main()

‎control/tests/run_all.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

‎control/tests/sisotool_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def test_sisotool(self):
6262
step_response_moved=np.array([[0.,0.02458187,0.16529784 ,0.46602716 ,0.91012035 ,1.43364313,1.93996334 ,2.3190105 ,2.47041552 ,2.32724853] ])
6363
assert_array_almost_equal(ax_step.lines[0].get_data()[1][:10],step_response_moved)
6464

65-
deftest_suite():
66-
returnunittest.TestLoader().loadTestsFromTestCase(TestSisotool)
6765

6866
if__name__=="__main__":
6967
unittest.main()

‎control/tests/slycot_convert_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ def testFreqResp(self):
192192
decimal=2)
193193

194194

195-
# These are here for once the above is made into a unittest.
196-
defsuite():
197-
returnunittest.TestLoader().loadTestsFromTestCase(TestSlycot)
198-
199195
if__name__=='__main__':
200196
unittest.main()
201197

‎control/tests/statefbk_array_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,5 @@ def tearDown(self):
409409
reset_defaults()
410410

411411

412-
deftest_suite():
413-
414-
status1=unittest.TestLoader().loadTestsFromTestCase(TestStatefbk)
415-
status2=unittest.TestLoader().loadTestsFromTestCase(TestStatefbk)
416-
returnstatus1andstatus2
417-
418412
if__name__=='__main__':
419413
unittest.main()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp