comparison test.py @ 205:10a801240bfc

Merge
author fsavard
date Thu, 04 Mar 2010 08:21:43 -0500
parents 6ea5dcf0541e
children
comparison
equal deleted inserted replaced
204:e1f5f66dd7dd 205:10a801240bfc
1 import doctest, sys, pkgutil 1 import doctest, sys, pkgutil
2 2
3 def runTests(options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1): 3 def runTests():
4 import ift6266 4 import ift6266
5 predefs = ift6266.__dict__
6 for (_, name, ispkg) in pkgutil.walk_packages(ift6266.__path__, ift6266.__name__+'.'): 5 for (_, name, ispkg) in pkgutil.walk_packages(ift6266.__path__, ift6266.__name__+'.'):
7 if not ispkg: 6 if not ispkg:
8 if name.startswith('ift6266.scripts.') or \ 7 if name.startswith('ift6266.scripts.') or \
9 name.startswith('ift6266.data_generation.transformations.pycaptcha.') or \ 8 name.startswith('ift6266.data_generation.transformations.pycaptcha.') or \
10 name in ['ift6266.test', 9 name in ['ift6266.test',
11 'ift6266.data_generation.transformations.testmod', 10 'ift6266.data_generation.transformations.testmod',
12 'ift6266.data_generation.transformations.gimp_script']: 11 'ift6266.data_generation.transformations.gimp_script']:
13 continue 12 continue
14 print "Testing:", name 13 test(name)
15 __import__(name) 14
16 doctest.testmod(sys.modules[name], extraglobs=predefs, optionflags=options) 15 def test(name):
16 import ift6266
17 predefs = ift6266.__dict__
18 options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1
19 print "Testing:", name
20 __import__(name)
21 doctest.testmod(sys.modules[name], extraglobs=predefs, optionflags=options)
17 22
18 if __name__ == '__main__': 23 if __name__ == '__main__':
19 runTests() 24 if len(sys.argv) > 1:
25 for mod in sys.argv[1:]:
26 if mod.endswith('.py'):
27 mod = mod[:-3]
28 test(mod)
29 else:
30 runTests()