本文整理汇总了Python中coverage.collector.Collector.get_arc_data方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.get_arc_data方法的具体用法?Python Collector.get_arc_data怎么用?Python Collector.get_arc_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.collector.Collector
的用法示例。
在下文中一共展示了Collector.get_arc_data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import get_arc_data [as 别名]
#.........这里部分代码省略.........
)
self._harvest_data()
self.data.write(suffix=data_suffix)
def combine(self):
"""Combine together a number of similarly-named coverage data files.
All coverage data files whose name starts with `data_file` (from the
coverage() constructor) will be read, and combined together into the
current measurements.
"""
aliases = None
if self.config.paths:
aliases = PathAliases(self.file_locator)
for paths in self.config.paths.values():
result = paths[0]
for pattern in paths[1:]:
aliases.add(pattern, result)
self.data.combine_parallel_data(aliases=aliases)
def _harvest_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
"""
if not self._measured:
return
# TODO: seems like this parallel structure is getting kinda old...
self.data.add_line_data(self.collector.get_line_data())
self.data.add_arc_data(self.collector.get_arc_data())
self.data.add_plugin_data(self.collector.get_plugin_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.
def analysis(self, morf):
"""Like `analysis2` but doesn't return excluded line numbers."""
f, s, _, m, mf = self.analysis2(morf)
示例2: Coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import get_arc_data [as 别名]
#.........这里部分代码省略.........
self._harvest_data()
self.data.write(suffix=data_suffix)
def combine(self):
"""Combine together a number of similarly-named coverage data files.
All coverage data files whose name starts with `data_file` (from the
coverage() constructor) will be read, and combined together into the
current measurements.
"""
self._init()
aliases = None
if self.config.paths:
aliases = PathAliases(self.file_locator)
for paths in self.config.paths.values():
result = paths[0]
for pattern in paths[1:]:
aliases.add(pattern, result)
self.data.combine_parallel_data(aliases=aliases)
def _harvest_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
"""
self._init()
if not self._measured:
return
# TODO: seems like this parallel structure is getting kinda old...
self.data.add_line_data(self.collector.get_line_data())
self.data.add_arc_data(self.collector.get_arc_data())
self.data.add_plugin_data(self.collector.get_plugin_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:
if pkg not in sys.modules:
self._warn("Module %s was never imported." % pkg)
elif not (
hasattr(sys.modules[pkg], '__file__') and
os.path.exists(sys.modules[pkg].__file__)
):
self._warn("Module %s has no Python source." % pkg)
else:
self._warn(
"Module %s was previously imported, "
"but not measured." % 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
示例3: coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import get_arc_data [as 别名]
#.........这里部分代码省略.........
return getattr(self.config, which + '_list')
def save(self):
data_suffix = self.data_suffix
if data_suffix is True:
extra = ''
if _TEST_NAME_FILE:
f = open(_TEST_NAME_FILE)
test_name = f.read()
f.close()
extra = '.' + test_name
data_suffix = '%s%s.%s.%06d' % (socket.gethostname(),
extra,
os.getpid(),
random.randint(0, 999999))
self._harvest_data()
self.data.write(suffix=data_suffix)
def combine(self):
aliases = None
if self.config.paths:
aliases = PathAliases(self.file_locator)
for paths in self.config.paths.values():
result = paths[0]
for pattern in paths[1:]:
aliases.add(pattern, result)
self.data.combine_parallel_data(aliases=aliases)
def _harvest_data(self):
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 self._warn_unimported_source:
for pkg in self.source_pkgs:
self._warn('Module %s was never imported.' % pkg)
summary = self.data.summary()
if not summary and self._warn_no_data:
self._warn('No data was collected.')
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):
continue
self.data.touch_file(py_file)
self._measured = False
def analysis(self, morf):
f, s, _, m, mf = self.analysis2(morf)
return (f,
s,
m,
mf)
def analysis2(self, morf):
analysis = self._analyze(morf)
return (analysis.filename,
analysis.statements,
analysis.excluded,
analysis.missing,
analysis.missing_formatted())
示例4: coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import get_arc_data [as 别名]
#.........这里部分代码省略.........
"""Save the collected coverage data to the data file."""
data_suffix = self.data_suffix
if data_suffix is True:
# If data_suffix was a simple true value, then make a suffix with
# plenty of distinguishing information. We do this here in
# `save()` at the last minute so that the pid will be correct even
# if the process forks.
data_suffix = "%s.%s.%06d" % (
self.socket.gethostname(), self.os.getpid(),
self.random.randint(0, 99999)
)
self._harvest_data()
self.data.write(suffix=data_suffix)
def combine(self):
"""Combine together a number of similarly-named coverage data files.
All coverage data files whose name starts with `data_file` (from the
coverage() constructor) will be read, and combined together into the
current measurements.
"""
self.data.combine_parallel_data()
def _harvest_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
"""
if not self._harvested:
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.
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:
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):
self.data.touch_file(py_file)
self._harvested = True
# Backward compatibility with version 1.
def analysis(self, morf):
"""Like `analysis2` but doesn't return excluded line numbers."""
f, s, _, m, mf = self.analysis2(morf)
return f, s, m, mf
def analysis2(self, morf):
"""Analyze a module.
`morf` is a module or a filename. It will be analyzed to determine
its coverage statistics. The return value is a 5-tuple:
* The filename for the module.
示例5: coverage
# 需要导入模块: from coverage.collector import Collector [as 别名]
# 或者: from coverage.collector.Collector import get_arc_data [as 别名]
#.........这里部分代码省略.........
"""Exclude source lines from execution consideration.
`regex` is a regular expression. Lines matching this expression are
not considered executable when reporting code coverage. A list of
regexes is maintained; this function adds a new regex to the list.
Matching any of the regexes excludes a source line.
"""
self.exclude_list.append(regex)
self.exclude_re = "(" + ")|(".join(self.exclude_list) + ")"
def get_exclude_list(self):
"""Return the list of excluded regex patterns."""
return self.exclude_list
def save(self):
"""Save the collected coverage data to the data file."""
self._harvest_data()
self.data.write()
def combine(self):
"""Combine together a number of similarly-named coverage data files.
All coverage data files whose name starts with `data_file` (from the
coverage() constructor) will be read, and combined together into the
current measurements.
"""
self.data.combine_parallel_data()
def _harvest_data(self):
"""Get the collected data and reset the collector."""
self.data.add_line_data(self.collector.get_line_data())
self.data.add_arc_data(self.collector.get_arc_data())
self.collector.reset()
# Backward compatibility with version 1.
def analysis(self, morf):
"""Like `analysis2` but doesn't return excluded line numbers."""
f, s, _, m, mf = self.analysis2(morf)
return f, s, m, mf
def analysis2(self, morf):
"""Analyze a module.
`morf` is a module or a filename. It will be analyzed to determine
its coverage statistics. The return value is a 5-tuple:
* The filename for the module.
* A list of line numbers of executable statements.
* A list of line numbers of excluded statements.
* A list of line numbers of statements not run (missing from execution).
* A readable formatted string of the missing line numbers.
The analysis uses the source file itself and the current measured
coverage data.
"""
analysis = self._analyze(morf)
return (
analysis.filename, analysis.statements, analysis.excluded,
analysis.missing, analysis.missing_formatted()
)
def _analyze(self, it):
"""Analyze a single morf or code unit.