[wwwsearch-commits] r41240 - wwwsearch/mechanize/trunk

jjlee at codespeak.net jjlee at codespeak.net
Sat Mar 24 17:10:09 CET 2007


Author: jjlee
Date: Sat Mar 24 17:10:07 2007
New Revision: 41240

Modified:
   wwwsearch/mechanize/trunk/test.py
Log:
Add -u switch to skip unittests (and only run the doctests)

Modified: wwwsearch/mechanize/trunk/test.py
==============================================================================
--- wwwsearch/mechanize/trunk/test.py	(original)
+++ wwwsearch/mechanize/trunk/test.py	Sat Mar 24 17:10:07 2007
@@ -144,6 +144,9 @@
     run_doctests = "-d" not in sys.argv
     if not run_doctests:
         sys.argv.remove("-d")
+    run_unittests = "-u" not in sys.argv
+    if not run_unittests:
+        sys.argv.remove("-u")
 
     # import local copy of Python 2.5 doctest
     assert os.path.isdir("test")
@@ -165,6 +168,11 @@
 
     import mechanize
 
+    class DefaultResult:
+        def wasSuccessful(self):
+            return True
+    result = DefaultResult()
+
     if run_doctests:
         # run .doctest files needing special support
         common_globs = {"mechanize": mechanize}
@@ -202,15 +210,16 @@
         doctest.testmod(_pullparser)
         doctest.testmod(_http)
 
-    # run vanilla unittest tests
-    import unittest
-    test_path = os.path.join(os.path.dirname(sys.argv[0]), "test")
-    sys.path.insert(0, test_path)
-    test_runner = None
-    if use_cgitb:
-        test_runner = CgitbTextTestRunner()
-    prog = TestProgram(MODULE_NAMES, testRunner=test_runner)
-    result = prog.runTests()
+    if run_unittests:
+        # run vanilla unittest tests
+        import unittest
+        test_path = os.path.join(os.path.dirname(sys.argv[0]), "test")
+        sys.path.insert(0, test_path)
+        test_runner = None
+        if use_cgitb:
+            test_runner = CgitbTextTestRunner()
+        prog = TestProgram(MODULE_NAMES, testRunner=test_runner)
+        result = prog.runTests()
 
     if run_coverage:
         # HTML coverage report


More information about the wwwsearch-commits mailing list