本文整理汇总了Python中coverage.collector.Collector.switch_context方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.switch_context方法的具体用法?Python Collector.switch_context怎么用?Python Collector.switch_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.collector.Collector
的用法示例。
在下文中一共展示了Collector.switch_context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import switch_context [as 别名]
#.........这里部分代码省略.........
self._collector.start()
self._started = True
def stop(self):
"""Stop measuring code coverage."""
if self._started:
self._collector.stop()
self._started = False
def _atexit(self):
"""Clean up on process shutdown."""
if self._debug.should("process"):
self._debug.write("atexit: {0!r}".format(self))
if self._started:
self.stop()
if self._auto_save:
self.save()
def erase(self):
"""Erase previously-collected coverage data.
This removes the in-memory data collected in this session as well as
discarding the data file.
"""
self._init()
self._post_init()
if self._collector:
self._collector.reset()
self._init_data(suffix=None)
self._data.erase(parallel=self.config.parallel)
self._data = None
def switch_context(self, new_context):
"""Switch to a new dynamic context.
`new_context` is a string to use as the context label
for collected data. If a :ref:`static context <static_contexts>` is in
use, the static and dynamic context labels will be joined together with
a pipe character.
Coverage collection must be started already.
.. versionadded:: 5.0
"""
if not self._started:
raise CoverageException( # pragma: only jython
"Cannot switch context, coverage is not started"
)
self._collector.switch_context(new_context)
def clear_exclude(self, which='exclude'):
"""Clear the exclude list."""
self._init()
setattr(self.config, which + "_list", [])
self._exclude_regex_stale()
def exclude(self, regex, which='exclude'):
"""Exclude source lines from execution consideration.
A number of lists of regular expressions are maintained. Each list
selects lines that are treated differently during reporting.
`which` determines which list is modified. The "exclude" list selects
lines that are not considered executable at all. The "partial" list
indicates lines with branches that are not taken.