Skip to content

Commit b39f02e

Browse files
author
Kevin Chen
committed
minor changes to test.py
bbelson@rainier.princeton.edu
1 parent 180080d commit b39f02e

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

src/test.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def findTests(testdir='./'):
5656
###############################################################################
5757

5858

59-
def tests():
59+
def tests(verbosity=2):
6060
import unittest
6161
try: #auto test discovery is only implemented in python 2.7+
6262
start_dir='./' #change to a tests directory eventually.
@@ -74,19 +74,13 @@ def tests():
7474
t.run(tests)
7575
print 'Completed tests in',mod
7676
except:
77-
#If can't do auto discovery, for now it is hard-coded. This is not ideal for
78-
#when new tests are added or existing ones are reorganized/renamed.
79-
80-
#remove all of the print commands once tests are debugged and converted to
81-
#unittests.
82-
83-
print 'Tests may be incomplete'
84-
t=unittest.TextTestRunner()
85-
77+
#find the modules ourselves without unittest discovery
8678
testModules = findTests()
79+
print 'Tests may be incomplete, will attempt to run tests in modules:'
80+
for m in testModules:
81+
print m
8782

88-
suite = unittest.TestSuite()
89-
suiteList=[]
83+
suiteList=[] #list of unittest.TestSuite objects
9084
for mod in testModules:
9185
exec('import '+mod+' as currentModule')
9286
#After tests have been debugged and made into unittests, remove
@@ -101,8 +95,8 @@ def tests():
10195
print 'The test module '+mod+' doesnt have '+\
10296
'a proper suite() function that returns a unittest.TestSuite object'+\
10397
' Please fix this!'
104-
alltests = unittest.TestSuite(suiteList)
105-
t.run(unittest.TestSuite(alltests))
98+
t=unittest.TextTestRunner(verbosity=verbosity)
99+
t.run(unittest.TestSuite(unittest.TestSuite(suiteList)))
106100

107101
###############################################################################
108102

0 commit comments

Comments
 (0)