本文整理汇总了Python中coverage.data.CoverageDataFiles.combine_parallel_data方法的典型用法代码示例。如果您正苦于以下问题:Python CoverageDataFiles.combine_parallel_data方法的具体用法?Python CoverageDataFiles.combine_parallel_data怎么用?Python CoverageDataFiles.combine_parallel_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.data.CoverageDataFiles
的用法示例。
在下文中一共展示了CoverageDataFiles.combine_parallel_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Coverage
# 需要导入模块: from coverage.data import CoverageDataFiles [as 别名]
# 或者: from coverage.data.CoverageDataFiles import combine_parallel_data [as 别名]
#.........这里部分代码省略.........
def save(self):
"""Save the collected coverage data to the data file."""
self._init()
self.get_data()
self.data_files.write(self.data, suffix=self.data_suffix)
def combine(self, data_paths=None):
"""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.
`data_paths` is a list of files or directories from which data should
be combined. If no list is passed, then the data files from the
directory indicated by the current data file (probably the current
directory) will be combined.
.. versionadded:: 4.0
The `data_paths` parameter.
"""
self._init()
self.get_data()
aliases = None
if self.config.paths:
aliases = PathAliases()
for paths in self.config.paths.values():
result = paths[0]
for pattern in paths[1:]:
aliases.add(pattern, result)
self.data_files.combine_parallel_data(self.data, aliases=aliases, data_paths=data_paths)
def get_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
Returns a :class:`coverage.CoverageData`, the collected coverage data.
.. versionadded:: 4.0
"""
self._init()
if not self._measured:
return self.data
self.collector.save_data(self.data)
# 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.
示例2: CoverageDataFilesTest
# 需要导入模块: from coverage.data import CoverageDataFiles [as 别名]
# 或者: from coverage.data.CoverageDataFiles import combine_parallel_data [as 别名]
#.........这里部分代码省略.........
covdata1.set_lines(LINES_1)
self.data_files.write(covdata1, suffix=True)
self.assert_doesnt_exist(".coverage")
data_files1 = glob.glob(".coverage.*")
self.assertEqual(len(data_files1), 1)
# Another suffix=True will choose a different name.
covdata2 = CoverageData()
covdata2.set_lines(LINES_1)
self.data_files.write(covdata2, suffix=True)
self.assert_doesnt_exist(".coverage")
data_files2 = glob.glob(".coverage.*")
self.assertEqual(len(data_files2), 2)
# In addition to being different, the suffixes have the pid in them.
self.assertTrue(all(str(os.getpid()) in fn for fn in data_files2))
def test_combining(self):
self.assert_doesnt_exist(".coverage.1")
self.assert_doesnt_exist(".coverage.2")
covdata1 = CoverageData()
covdata1.set_lines(LINES_1)
self.data_files.write(covdata1, suffix='1')
self.assert_exists(".coverage.1")
self.assert_doesnt_exist(".coverage.2")
covdata2 = CoverageData()
covdata2.set_lines(LINES_2)
self.data_files.write(covdata2, suffix='2')
self.assert_exists(".coverage.2")
covdata3 = CoverageData()
self.data_files.combine_parallel_data(covdata3)
self.assert_line_counts(covdata3, SUMMARY_1_2)
self.assert_measured_files(covdata3, MEASURED_FILES_1_2)
self.assert_doesnt_exist(".coverage.1")
self.assert_doesnt_exist(".coverage.2")
def test_erasing(self):
covdata1 = CoverageData()
covdata1.set_lines(LINES_1)
self.data_files.write(covdata1)
covdata1.erase()
self.assert_line_counts(covdata1, {})
self.data_files.erase()
covdata2 = CoverageData()
self.data_files.read(covdata2)
self.assert_line_counts(covdata2, {})
def read_json_data_file(self, fname):
"""Read a JSON data file for testing the JSON directly."""
with open(fname, 'r') as fdata:
go_away = fdata.read(len(CoverageData._GO_AWAY))
self.assertEqual(go_away, CoverageData._GO_AWAY)
return json.load(fdata)
def test_file_format(self):
# Write with CoverageData, then read the JSON explicitly.
covdata = CoverageData()
covdata.set_lines(LINES_1)
self.data_files.write(covdata)
data = self.read_json_data_file(".coverage")