# HG changeset patch
# User Arnaud Bergeron <abergeron@gmail.com>
# Date 1267567259 18000
# Node ID 92ee9896020d5c808b77abb7685a77320920ce6a
# Parent  0d0677773533915e90824b85688f641fbb0202cd
Add option to test a module given on the command line.

diff -r 0d0677773533 -r 92ee9896020d test.py
--- a/test.py	Mon Mar 01 17:06:49 2010 -0500
+++ b/test.py	Tue Mar 02 17:00:59 2010 -0500
@@ -1,8 +1,7 @@
 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__+'.'):
         if not ispkg:
             if name.startswith('ift6266.scripts.') or \
@@ -11,9 +10,18 @@
                         '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)
+            test(name)
 
+def test(name, options = doctest.ELLIPSIS or doctest.DONT_ACCEPT_TRUE_FOR_1):
+    import ift6266
+    predefs = ift6266.__dict__
+    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:]:
+            test(mod)
+    else:
+        runTests()