[Checkins] SVN: z3c.coverage/trunk/src/z3c/coverage/coveragediff.
Make the --web-url option work when not using email.
Marius Gedminas
marius at pov.lt
Thu Jul 19 11:35:50 EDT 2007
Log message for revision 78162:
Make the --web-url option work when not using email.
Changed:
U z3c.coverage/trunk/src/z3c/coverage/coveragediff.py
U z3c.coverage/trunk/src/z3c/coverage/coveragediff.txt
-=-
Modified: z3c.coverage/trunk/src/z3c/coverage/coveragediff.py
===================================================================
--- z3c.coverage/trunk/src/z3c/coverage/coveragediff.py 2007-07-19 15:30:51 UTC (rev 78161)
+++ z3c.coverage/trunk/src/z3c/coverage/coveragediff.py 2007-07-19 15:35:49 UTC (rev 78162)
@@ -240,6 +240,22 @@
smtp.quit()
+class ReportPrinter(object):
+ """Reporter to sys.stdout."""
+
+ def __init__(self, web_url=None):
+ self.web_url = web_url
+
+ def warn(self, filename, message):
+ """Warn about test coverage regression."""
+ module = strip(os.path.basename(filename), '.cover')
+ print '%s: %s' % (module, message)
+ if self.web_url:
+ url = urljoin(self.web_url, module + '.html')
+ print 'See ' + url
+ print
+
+
class ReportEmailer(object):
"""Warning collector and emailer."""
@@ -310,12 +326,11 @@
parser.error("wrong number of arguments")
olddir, newdir = args
if opts.email:
- mailer = ReportEmailer(opts.sender, opts.email, opts.subject, opts.web_url)
- warnfunc = mailer.warn
+ reporter = ReportEmailer(opts.sender, opts.email, opts.subject, opts.web_url)
else:
- warnfunc = warn
+ reporter = ReportPrinter(opts.web_url)
compare_dirs(olddir, newdir, include=opts.include, exclude=opts.exclude,
- warn=warnfunc)
+ warn=reporter.warn)
if opts.email:
mailer.send()
Modified: z3c.coverage/trunk/src/z3c/coverage/coveragediff.txt
===================================================================
--- z3c.coverage/trunk/src/z3c/coverage/coveragediff.txt 2007-07-19 15:30:51 UTC (rev 78161)
+++ z3c.coverage/trunk/src/z3c/coverage/coveragediff.txt 2007-07-19 15:35:49 UTC (rev 78162)
@@ -9,10 +9,45 @@
a test suite.
+ReportPrinter
+-------------
+
+The ``ReportPrinter`` class is responsible for formatting the output.
+
+ >>> from z3c.coverage.coveragediff import ReportPrinter
+ >>> printer = ReportPrinter()
+ >>> printer.warn('/tmp/coverage/z3c.coverage.coveragediff.cover',
+ ... '3 new untested lines')
+ z3c.coverage.coveragediff: 3 new untested lines
+ >>> printer.warn('/tmp/coverage/z3c.coverage.coveragereport.cover',
+ ... '2 new untested lines')
+ z3c.coverage.coveragereport: 2 new untested lines
+
+
+Links to web pages
+~~~~~~~~~~~~~~~~~~
+
+Report printer can also include links to web pages with the coverage reports
+(e.g. the ones you can get from ``coveragereport``).
+
+ >>> printer = ReportPrinter(web_url='http://example.com/coverage/')
+ >>> printer.warn('/tmp/coverage/z3c.coverage.coveragediff.cover',
+ ... '3 new untested lines')
+ z3c.coverage.coveragediff: 3 new untested lines
+ See http://example.com/coverage/z3c.coverage.coveragediff.html
+ <BLANKLINE>
+ >>> printer.warn('/tmp/coverage/z3c.coverage.coveragereport.cover',
+ ... '2 new untested lines')
+ z3c.coverage.coveragereport: 2 new untested lines
+ See http://example.com/coverage/z3c.coverage.coveragereport.html
+ <BLANKLINE>
+
+
ReportEmailer
-------------
-The ``ReportEmailer`` class collects warnings and sends them via email.
+The ``ReportEmailer`` class is an alternative to ``ReportPrinter``. It
+collects warnings and sends them via email.
You pass the basic email parameters (sender, recipient and subject line)
to the constructor:
More information about the Checkins
mailing list