Menu

[d29355]: / tests.py  Maximize  Restore  History

Download this file

25 lines (21 with data), 577 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import unittest
def mymodels():
import glob, os.path
ff ='''
def test_{name}(me):
print(' >>> Testing model: {name}')
import models.{name}
'''
for f in glob.glob('models/[a-z]*[.]py'):
with open(f) as h:
for l in h:
if 'pymprog' in l:
f = os.path.split(f)[1][:-3]
print(f)
yield ff.format(name=f)
break
class TestExamples(unittest.TestCase):
for code in mymodels():
exec(code)
if __name__ == '__main__':
unittest.main()