本文整理汇总了Python中coverage.files.PathAliases.add方法的典型用法代码示例。如果您正苦于以下问题:Python PathAliases.add方法的具体用法?Python PathAliases.add怎么用?Python PathAliases.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.files.PathAliases
的用法示例。
在下文中一共展示了PathAliases.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_combining_with_aliases
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_combining_with_aliases(self):
covdata1 = CoverageData()
covdata1.add_line_data({
'/home/ned/proj/src/a.py': {1: None, 2: None},
'/home/ned/proj/src/sub/b.py': {3: None},
})
covdata1.write(suffix='1')
covdata2 = CoverageData()
covdata2.add_line_data({
r'c:\ned\test\a.py': {4: None, 5: None},
r'c:\ned\test\sub\b.py': {6: None},
})
covdata2.write(suffix='2')
covdata3 = CoverageData()
aliases = PathAliases()
aliases.add("/home/ned/proj/src/", "./")
aliases.add(r"c:\ned\test", "./")
covdata3.combine_parallel_data(aliases=aliases)
apy = canonical_filename('./a.py')
sub_bpy = canonical_filename('./sub/b.py')
self.assert_summary(
covdata3, { apy: 4, sub_bpy: 2, }, fullpath=True
)
self.assert_measured_files(covdata3, [apy,sub_bpy])
示例2: combine
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
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)
示例3: test_combining_with_aliases
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_combining_with_aliases(self):
covdata1 = CoverageData()
covdata1.set_lines({
'/home/ned/proj/src/a.py': {1: None, 2: None},
'/home/ned/proj/src/sub/b.py': {3: None},
'/home/ned/proj/src/template.html': {10: None},
})
covdata1.set_file_tracers({
'/home/ned/proj/src/template.html': 'html.plugin',
})
self.data_files.write(covdata1, suffix='1')
covdata2 = CoverageData()
covdata2.set_lines({
r'c:\ned\test\a.py': {4: None, 5: None},
r'c:\ned\test\sub\b.py': {3: None, 6: None},
})
self.data_files.write(covdata2, suffix='2')
covdata3 = CoverageData()
aliases = PathAliases()
aliases.add("/home/ned/proj/src/", "./")
aliases.add(r"c:\ned\test", "./")
self.data_files.combine_parallel_data(covdata3, aliases=aliases)
apy = canonical_filename('./a.py')
sub_bpy = canonical_filename('./sub/b.py')
template_html = canonical_filename('./template.html')
self.assert_line_counts(covdata3, {apy: 4, sub_bpy: 2, template_html: 1}, fullpath=True)
self.assert_measured_files(covdata3, [apy, sub_bpy, template_html])
self.assertEqual(covdata3.file_tracer(template_html), 'html.plugin')
示例4: test_wildcard
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_wildcard(self):
aliases = PathAliases()
aliases.add('/ned/home/*/src', './mysrc')
self.assertEqual(aliases.map('/ned/home/foo/src/a.py'), './mysrc/a.py')
aliases = PathAliases()
aliases.add('/ned/home/*/src/', './mysrc')
self.assertEqual(aliases.map('/ned/home/foo/src/a.py'), './mysrc/a.py')
示例5: test_multiple_wildcard
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_multiple_wildcard(self):
aliases = PathAliases()
aliases.add('/home/jenkins/*/a/*/b/*/django', './django')
self.assert_mapped(
aliases,
'/home/jenkins/xx/a/yy/b/zz/django/foo/bar.py',
'./django/foo/bar.py'
)
示例6: test_wildcard
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_wildcard(self):
aliases = PathAliases()
aliases.add('/ned/home/*/src', './mysrc')
self.assert_mapped(aliases, '/ned/home/foo/src/a.py', './mysrc/a.py')
aliases = PathAliases()
aliases.add('/ned/home/*/src/', './mysrc')
self.assert_mapped(aliases, '/ned/home/foo/src/a.py', './mysrc/a.py')
示例7: create_path_aliases_from_coverage
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def create_path_aliases_from_coverage(coverage):
aliases = PathAliases()
if coverage and coverage.config.paths:
for paths in coverage.config.paths.values():
result = paths[0]
for pattern in paths[1:]:
aliases.add(pattern, result)
return aliases
示例8: apply_path_aliases
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def apply_path_aliases(cov, alias_map):
"""Adjust filenames in coverage data."""
data = CoverageData()
aliases = PathAliases()
for k, v in alias_map.items():
aliases.add(k, v)
data.update(cov.data, aliases)
cov.data = data
示例9: combine
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
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)
示例10: test_dot
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_dot(self):
for d in ('.', '..', '../other', '~'):
aliases = PathAliases()
aliases.add(d, '/the/source')
the_file = os.path.join(d, 'a.py')
the_file = os.path.expanduser(the_file)
the_file = os.path.abspath(os.path.realpath(the_file))
assert '~' not in the_file # to be sure the test is pure.
self.assert_mapped(aliases, the_file, '/the/source/a.py')
示例11: test_linux_on_windows
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_linux_on_windows(self):
# https://bitbucket.org/ned/coveragepy/issues/618/problem-when-combining-windows-generated
lin = "*/project/module/"
win = "*\\project\\module\\"
# Try the paths in both orders.
for paths in [[lin, win], [win, lin]]:
aliases = PathAliases()
for path in paths:
aliases.add(path, "project\\module")
self.assert_mapped(
aliases,
"C:/a/path/somewhere/coveragepy_test/project/module/tests/file.py",
"project\\module\\tests\\file.py"
)
示例12: test_dot
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_dot(self):
cases = ['.', '..', '../other', '~']
if not env.WINDOWS:
# The root test case was added for the manylinux Docker images,
# and I'm not sure how it should work on Windows, so skip it.
cases += ['/']
for d in cases:
aliases = PathAliases()
aliases.add(d, '/the/source')
the_file = os.path.join(d, 'a.py')
the_file = os.path.expanduser(the_file)
the_file = os.path.abspath(os.path.realpath(the_file))
assert '~' not in the_file # to be sure the test is pure.
self.assert_mapped(aliases, the_file, '/the/source/a.py')
示例13: combine
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
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)
示例14: test_paths_are_os_corrected
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_paths_are_os_corrected(self):
aliases = PathAliases()
aliases.add('/home/ned/*/src', './mysrc')
aliases.add(r'c:\ned\src', './mysrc')
self.assert_mapped(aliases, r'C:\Ned\src\sub\a.py', './mysrc/sub/a.py')
aliases = PathAliases()
aliases.add('/home/ned/*/src', r'.\mysrc')
aliases.add(r'c:\ned\src', r'.\mysrc')
self.assert_mapped(aliases, r'/home/ned/foo/src/sub/a.py', r'.\mysrc\sub\a.py')
示例15: test_combining_with_aliases
# 需要导入模块: from coverage.files import PathAliases [as 别名]
# 或者: from coverage.files.PathAliases import add [as 别名]
def test_combining_with_aliases(self):
covdata1 = CoverageData()
covdata1.add_line_data(
{"/home/ned/proj/src/a.py": {1: None, 2: None}, "/home/ned/proj/src/sub/b.py": {3: None}}
)
covdata1.write(suffix="1")
covdata2 = CoverageData()
covdata2.add_line_data({r"c:\ned\test\a.py": {4: None, 5: None}, r"c:\ned\test\sub\b.py": {6: None}})
covdata2.write(suffix="2")
covdata3 = CoverageData()
aliases = PathAliases()
aliases.add("/home/ned/proj/src/", "./")
aliases.add(r"c:\ned\test", "./")
covdata3.combine_parallel_data(aliases=aliases)
self.assert_summary(covdata3, {"./a.py": 4, "./sub/b.py": 2}, fullpath=True)
self.assert_measured_files(covdata3, ["./a.py", "./sub/b.py"])