annotate test.py @ 197:9116cfe8e4ab

Add __init__.py files to the remaining directories that miss them.
author Arnaud Bergeron <abergeron@gmail.com>
date Tue, 02 Mar 2010 18:03:42 -0500
parents 92c9a6c48ce9
children 6ea5dcf0541e
rev   line source
160
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
1 import doctest, sys, pkgutil
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
2
195
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
3 def runTests():
160
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
4 import ift6266
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
5 predefs = ift6266.__dict__
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
6 for (_, name, ispkg) in pkgutil.walk_packages(ift6266.__path__, ift6266.__name__+'.'):
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
7 if not ispkg:
174
ff26436d42d6 Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents: 162
diff changeset
8 if name.startswith('ift6266.scripts.') or \
ff26436d42d6 Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents: 162
diff changeset
9 name.startswith('ift6266.data_generation.transformations.pycaptcha.') or \
ff26436d42d6 Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents: 162
diff changeset
10 name in ['ift6266.test',
ff26436d42d6 Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents: 162
diff changeset
11 'ift6266.data_generation.transformations.testmod',
ff26436d42d6 Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents: 162
diff changeset
12 'ift6266.data_generation.transformations.gimp_script']:
160
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
13 continue
195
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
14
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
15 def test(name):
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
16 import ift6266
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
17 predefs = ift6266.__dict__
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
18 options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
19 print "Testing:", name
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
20 __import__(name)
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
21 doctest.testmod(sys.modules[name], extraglobs=predefs, optionflags=options)
160
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
22
68160fd149fe Simple script to doctest all modules beneath ift6266.
Arnaud Bergeron <abergeron@gmail.com>
parents:
diff changeset
23 if __name__ == '__main__':
195
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
24 if len(sys.argv) > 1:
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
25 for mod in sys.argv[1:]:
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
26 if mod.endswith('.py'):
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
27 mod = mod[:-3]
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
28 test(mod)
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
29 else:
92c9a6c48ce9 Add option for test.py to test modules specified on the command-line.
Arnaud Bergeron <abergeron@gmail.com>
parents: 174
diff changeset
30 runTests()