Skip to content

Commit 6b24bb4

Browse files
murrayrmbnavigator
andauthored
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.py Co-authored-by: bnavigator <code@bnavigator.de>
1 parent 3b19ae9 commit 6b24bb4

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 run setup.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
except ImportError:
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-
from numpy.testing import Tester
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 - test suit for block diagram algebra
3+
# bdalg_test.py - test suite for block diagram algebra
44
# RMM, 30 Mar 2011 (based on TestBDAlg from v0.4a)
55

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

273273

274-
def suite():
275-
return unittest.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-
def suite():
292-
return unittest.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-
def suite():
222-
return unittest.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-
def suite():
272-
return unittest.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-
def test_suite():
62-
return unittest.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
import unittest
77
import numpy as np
8-
from control import *
8+
from control import StateSpace, TransferFunction, feedback, step_response, \
9+
isdtime, timebase, isctime, sample_system, bode, impulse_response, \
10+
timebaseEqual, forced_response
911
from control import matlab
1012

1113
class TestDiscrete(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-
def suite():
386-
return unittest.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-
def suite():
131-
return unittest.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-
def suite():
419-
return unittest.TestLoader().loadTestsFromTestCase(TestFRD)
420-
421418
if __name__ == "__main__":
422419
unittest.main()

0 commit comments

Comments
 (0)