# HG changeset patch # User Arnaud Bergeron # Date 1267570882 18000 # Node ID 92c9a6c48ce9b83b3a1258d6fe0a407792fc46d7 # Parent 3632e6258642499640868362bfe9bd294429b5c2 Add option for test.py to test modules specified on the command-line. diff -r 3632e6258642 -r 92c9a6c48ce9 test.py --- a/test.py Tue Mar 02 14:47:18 2010 -0500 +++ b/test.py Tue Mar 02 18:01:22 2010 -0500 @@ -1,6 +1,6 @@ import doctest, sys, pkgutil -def runTests(options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1): +def runTests(): import ift6266 predefs = ift6266.__dict__ for (_, name, ispkg) in pkgutil.walk_packages(ift6266.__path__, ift6266.__name__+'.'): @@ -11,9 +11,20 @@ 'ift6266.data_generation.transformations.testmod', 'ift6266.data_generation.transformations.gimp_script']: continue - print "Testing:", name - __import__(name) - doctest.testmod(sys.modules[name], extraglobs=predefs, optionflags=options) + +def test(name): + import ift6266 + predefs = ift6266.__dict__ + options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1 + print "Testing:", name + __import__(name) + doctest.testmod(sys.modules[name], extraglobs=predefs, optionflags=options) if __name__ == '__main__': - runTests() + if len(sys.argv) > 1: + for mod in sys.argv[1:]: + if mod.endswith('.py'): + mod = mod[:-3] + test(mod) + else: + runTests()