[wwwsearch-commits] r32925 - in wwwsearch/mechanize/trunk: . test-tools
jjlee at codespeak.net
jjlee at codespeak.net
Fri Oct 6 01:03:50 CEST 2006
Author: jjlee
Date: Fri Oct 6 01:03:48 2006
New Revision: 32925
Modified:
wwwsearch/mechanize/trunk/test-tools/doctest.py
wwwsearch/mechanize/trunk/test.py
Log:
Fix biggest coverage measurement problem (thanks to Ned Batchelder). There are still some oddities, though.
Modified: wwwsearch/mechanize/trunk/test-tools/doctest.py
==============================================================================
--- wwwsearch/mechanize/trunk/test-tools/doctest.py (original)
+++ wwwsearch/mechanize/trunk/test-tools/doctest.py Fri Oct 6 01:03:48 2006
@@ -353,8 +353,19 @@
"""
def __init__(self, out):
self.__out = out
+ self.__debugger_used = False
pdb.Pdb.__init__(self)
+ def set_trace(self):
+ self.__debugger_used = True
+ pdb.Pdb.set_trace(self)
+
+ def set_continue(self):
+ # Calling set_continue unconditionally would break unit test coverage
+ # reporting, as Bdb.set_continue calls sys.settrace(None).
+ if self.__debugger_used:
+ pdb.Pdb.set_continue(self)
+
def trace_dispatch(self, *args):
# Redirect stdout to the given stream.
save_stdout = sys.stdout
Modified: wwwsearch/mechanize/trunk/test.py
==============================================================================
--- wwwsearch/mechanize/trunk/test.py (original)
+++ wwwsearch/mechanize/trunk/test.py Fri Oct 6 01:03:48 2006
@@ -179,17 +179,22 @@
if run_coverage:
# HTML coverage report
## import colorize
- from mechanize import _mechanize
## try:
## os.mkdir("coverage")
## except OSError:
## pass
-## f, s, m, mf = coverage.analysis(_mechanize)
-## fo = open(os.path.join('coverage', os.path.basename(f)+'.html'), 'wb')
-## colorize.colorize_file(f, outstream=fo, not_covered=mf)
-## fo.close()
- coverage.report(_mechanize)
- #print coverage.analysis(_mechanize)
+ private_modules = glob.glob("mechanize/_*.py")
+ private_modules.remove("mechanize/__init__.py")
+ for module_filename in private_modules:
+ module_name = module_filename.replace("/", ".")[:-3]
+ print module_name
+ module = sys.modules[module_name]
+## f, s, m, mf = coverage.analysis(module)
+## fo = open(os.path.join('coverage', os.path.basename(f)+'.html'), 'wb')
+## colorize.colorize_file(f, outstream=fo, not_covered=mf)
+## fo.close()
+ coverage.report(module)
+ #print coverage.analysis(module)
# XXX exit status is wrong -- does not take account of doctests
sys.exit(not result.wasSuccessful())
More information about the wwwsearch-commits
mailing list