Skip to content
Snippets Groups Projects
Commit e1bf1b9b authored by Henning Glawe's avatar Henning Glawe
Browse files

add coverageIgnore kwarg to SimpleMatcher

allows to make 'local' SM equivalent to global 'superContext.coverageIgnore'
e.g. a SM with SM.does_nothing=True appears the same as a sub-expression
of superContext.coverageIgnore if SM.coverageIgnore==True in annotated
output.
parent 1e9bbd1f
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,9 @@ class Annotator(object):
ignore = False
matcher_does_nothing = False
if match:
if matcher.does_nothing:
if matcher.coverageIgnore:
ignore = True
elif matcher.does_nothing:
matcher_does_nothing = True
else:
m2 = RE_EMPTY.match(line)
......
......@@ -73,6 +73,7 @@ class SimpleMatcher(object):
dependencies={},
defLine=0,
defFile='',
coverageIgnore=False, # mark line as ignored in coverage analysis
):
self.index = -1
self.startReStr = startReStr
......@@ -110,6 +111,13 @@ class SimpleMatcher(object):
elif endReStr is not None and len(extractGroupNames(endReStr))>0:
self.does_nothing = False
self.coverageIgnore = coverageIgnore
if coverageIgnore and not self.does_nothing:
logger.warning(
"SimpleMatcher '%s' has an effect " +
"and is marked as coverageIgnore", name)
self.coverageIgnore = self.does_nothing and coverageIgnore
caller=inspect.currentframe()
if (defFile == '') and (defLine == 0):
if (caller is not None) and (caller.f_back is not None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment