Skip to content

Commit d8e5778

Browse files
committed
Update run_all tests to make it run in pycharm
1 parent 96868ec commit d8e5778

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

control/tests/run_all.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@
88
import re # regular expressions
99
import os # operating system commands
1010

11+
1112
def test_all(verbosity=0):
1213
""" Runs all tests written for python-control.
1314
"""
1415
try: # autodiscovery (python 2.7+)
1516
start_dir = './'
1617
pattern = '*_test.py'
1718
top_level_dir = '../'
18-
testModules = \
19-
unittest.defaultTestLoader.discover(start_dir, pattern=pattern, \
20-
top_level_dir=top_level_dir)
21-
22-
for mod in test_mods:
23-
print('Running tests in', mod)
24-
tests = unittest.defaultTestLoader.loadTestFromModule(mod)
19+
test_mods = unittest.defaultTestLoader.discover(start_dir, pattern=pattern,
20+
top_level_dir=top_level_dir)
21+
for suite in test_mods:
22+
print("Running tests in: ", suite)
2523
t = unittest.TextTestRunner()
26-
t.run(tests)
27-
print('Completed tests in', mod)
24+
t.run(suite)
2825

2926
except:
3027
testModules = findTests('./tests/')
@@ -33,8 +30,8 @@ def test_all(verbosity=0):
3330
for mod in testModules:
3431
print('Running tests in', mod)
3532
suiteList=[] # list of unittest.TestSuite objects
36-
exec('import '+mod+' as currentModule')
37-
33+
exec('import control.tests.'+mod+' as currentModule')
34+
print(currentModule.suite())
3835
try:
3936
currentSuite = currentModule.suite()
4037
if isinstance(currentSuite, unittest.TestSuite):

0 commit comments

Comments
 (0)