当前位置: 首页>>代码示例>>Python>>正文


Python files.PathAliases类代码示例

本文整理汇总了Python中coverage.files.PathAliases的典型用法代码示例。如果您正苦于以下问题:Python PathAliases类的具体用法?Python PathAliases怎么用?Python PathAliases使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PathAliases类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_combining_with_aliases

    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])
开发者ID:gabrielferreira,项目名称:coveragepy,代码行数:28,代码来源:test_data.py

示例2: combine

    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)
开发者ID:Athsheep,项目名称:Flask_Web_Development,代码行数:28,代码来源:control.py

示例3: test_combining_with_aliases

    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')
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:32,代码来源:test_data.py

示例4: test_multiple_wildcard

 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'
     )
开发者ID:hugovk,项目名称:coveragepy,代码行数:8,代码来源:test_files.py

示例5: create_path_aliases_from_coverage

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
开发者ID:AlejandroFrias,项目名称:smother,代码行数:8,代码来源:control.py

示例6: apply_path_aliases

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
开发者ID:zopefoundation,项目名称:z3c.coverage,代码行数:8,代码来源:coveragereport.py

示例7: test_paths_are_os_corrected

    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')
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:10,代码来源:test_files.py

示例8: combine

    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)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:10,代码来源:control.py

示例9: test_dot

    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')
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:10,代码来源:test_files.py

示例10: test_wildcard

 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')
开发者ID:phenoxim,项目名称:coveragepy,代码行数:7,代码来源:test_files.py

示例11: test_linux_on_windows

    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"
            )
开发者ID:hugovk,项目名称:coveragepy,代码行数:15,代码来源:test_files.py

示例12: test_dot

    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')
开发者ID:hugovk,项目名称:coveragepy,代码行数:15,代码来源:test_files.py

示例13: combine

    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)
开发者ID:fabio-ts,项目名称:unftt,代码行数:16,代码来源:control.py

示例14: test_combining_with_aliases

    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"])
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:18,代码来源:test_data.py

示例15: test_cant_have_wildcard_at_end

 def test_cant_have_wildcard_at_end(self):
     aliases = PathAliases()
     msg = "Pattern must not end with wildcards."
     with self.assertRaisesRegex(CoverageException, msg):
         aliases.add("/ned/home/*", "fooey")
     with self.assertRaisesRegex(CoverageException, msg):
         aliases.add("/ned/home/*/", "fooey")
     with self.assertRaisesRegex(CoverageException, msg):
         aliases.add("/ned/home/*/*/", "fooey")
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:9,代码来源:test_files.py


注:本文中的coverage.files.PathAliases类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。