本文整理匯總了Python中coverage.coverage.collector方法的典型用法代碼示例。如果您正苦於以下問題:Python coverage.collector方法的具體用法?Python coverage.collector怎麽用?Python coverage.collector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coverage.coverage
的用法示例。
在下文中一共展示了coverage.collector方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load
# 需要導入模塊: from coverage import coverage [as 別名]
# 或者: from coverage.coverage import collector [as 別名]
def load(self):
"""Load previously-collected coverage data from the data file."""
self.collector.reset()
self.data.read()
示例2: stop
# 需要導入模塊: from coverage import coverage [as 別名]
# 或者: from coverage.coverage import collector [as 別名]
def stop(self):
"""Stop measuring code coverage."""
self._started = False
self.collector.stop()
示例3: erase
# 需要導入模塊: from coverage import coverage [as 別名]
# 或者: from coverage.coverage import collector [as 別名]
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.collector.reset()
self.data.erase()
示例4: _harvest_data
# 需要導入模塊: from coverage import coverage [as 別名]
# 或者: from coverage.coverage import collector [as 別名]
def _harvest_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
"""
if not self._measured:
return
self.data.add_line_data(self.collector.get_line_data())
self.data.add_arc_data(self.collector.get_arc_data())
self.collector.reset()
# If there are still entries in the source_pkgs list, then we never
# encountered those packages.
if self._warn_unimported_source:
for pkg in self.source_pkgs:
self._warn("Module %s was never imported." % pkg)
# Find out if we got any data.
summary = self.data.summary()
if not summary and self._warn_no_data:
self._warn("No data was collected.")
# Find files that were never executed at all.
for src in self.source:
for py_file in find_python_files(src):
py_file = self.file_locator.canonical_filename(py_file)
if self.omit_match and self.omit_match.match(py_file):
# Turns out this file was omitted, so don't pull it back
# in as unexecuted.
continue
self.data.touch_file(py_file)
self._measured = False
# Backward compatibility with version 1.
示例5: start
# 需要導入模塊: from coverage import coverage [as 別名]
# 或者: from coverage.coverage import collector [as 別名]
def start(self):
"""Start measuring code coverage.
Coverage measurement actually occurs in functions called after `start`
is invoked. Statements in the same scope as `start` won't be measured.
Once you invoke `start`, you must also call `stop` eventually, or your
process might not shut down cleanly.
"""
if self.run_suffix:
# Calling start() means we're running code, so use the run_suffix
# as the data_suffix when we eventually save the data.
self.data_suffix = self.run_suffix
if self.auto_data:
self.load()
# Create the matchers we need for _should_trace
if self.source or self.source_pkgs:
self.source_match = TreeMatcher(self.source)
else:
if self.cover_dir:
self.cover_match = TreeMatcher([self.cover_dir])
if self.pylib_dirs:
self.pylib_match = TreeMatcher(self.pylib_dirs)
if self.include:
self.include_match = FnmatchMatcher(self.include)
if self.omit:
self.omit_match = FnmatchMatcher(self.omit)
# The user may want to debug things, show info if desired.
if self.debug.should('config'):
self.debug.write("Configuration values:")
config_info = sorted(self.config.__dict__.items())
self.debug.write_formatted_info(config_info)
if self.debug.should('sys'):
self.debug.write("Debugging info:")
self.debug.write_formatted_info(self.sysinfo())
self.collector.start()
self._started = True
self._measured = True