Class TestCoverageAnnotator
object --+
|
trac.core.Component --+
|
TestCoverageAnnotator
>>> from genshi.builder import tag
>>> from trac.test import Mock, MockPerm
>>> from trac.mimeview import Context
>>> from trac.util.datefmt import to_datetime, utc
>>> from trac.web.href import Href
>>> from bitten.model import BuildConfig, Build, Report
>>> from bitten.report.tests.coverage import env_stub_with_tables
>>> env = env_stub_with_tables()
>>> repos = Mock(get_changeset=lambda x: Mock(date=to_datetime(12345, utc)))
>>> env.get_repository = lambda: repos
>>> BuildConfig(env, name='trunk', path='trunk').insert()
>>> Build(env, rev=123, config='trunk', rev_time=12345, platform=1).insert()
>>> rpt = Report(env, build=1, step='test', category='coverage')
>>> rpt.items.append({'file': 'foo.py', 'line_hits': '5 - 0'})
>>> rpt.insert()
>>> ann = TestCoverageAnnotator(env)
>>> req = Mock(href=Href('/'), perm=MockPerm(),
... chrome={'warnings': []}, args={})
Version in the branch should not match:
>>> context = Context.from_request(req, 'source', '/branches/blah/foo.py', 123)
>>> ann.get_annotation_data(context)
[]
Version in the trunk should match:
>>> context = Context.from_request(req, 'source', '/trunk/foo.py', 123)
>>> data = ann.get_annotation_data(context)
>>> print data
[u'5', u'-', u'0']
>>> def annotate_row(lineno, line):
... row = tag.tr()
... ann.annotate_row(context, row, lineno, line, data)
... return row.generate().render('html')
>>> annotate_row(1, 'x = 1')
'<tr><th class="covered">5</th></tr>'
>>> annotate_row(2, '')
'<tr><th></th></tr>'
>>> annotate_row(3, 'y = x')
'<tr><th class="uncovered">0</th></tr>'
|
pre_process_request(self,
req,
handler) |
|
|
|
post_process_request(self,
req,
template,
data,
content_type)
Adds a 'Coverage' context navigation menu item. |
|
|
|
get_annotation_type(self) |
|
|
|
get_annotation_data(self,
context) |
|
|
|
annotate_row(self,
context,
row,
lineno,
line,
data) |
|
|
|
__init__(self,
compmgr,
init=None,
cls=<class 'bitten.report.coverage.TestCoverageAnnotator'>)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from trac.core.Component :
__new__ ,
implements
|
Inherited from object :
__class__
|
__init__(self,
compmgr,
init=None,
cls=<class 'bitten.report.coverage.TestCoverageAnnotator'>)
(Constructor)
|
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- Overrides:
object.__init__
- (inherited documentation)
|