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


Python XmlCoverageReporter.violations方法代码示例

本文整理汇总了Python中diff_cover.violations_reporter.XmlCoverageReporter.violations方法的典型用法代码示例。如果您正苦于以下问题:Python XmlCoverageReporter.violations方法的具体用法?Python XmlCoverageReporter.violations怎么用?Python XmlCoverageReporter.violations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在diff_cover.violations_reporter.XmlCoverageReporter的用法示例。


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

示例1: test_violations

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_violations(self):

        # Construct the XML report
        file_paths = ['file1.py', 'subdir/file2.py']
        violations = self.MANY_VIOLATIONS
        measured = self.FEW_MEASURED
        xml = self._coverage_xml(file_paths, violations, measured)

        # Parse the report
        coverage = XmlCoverageReporter(xml)

        # Expect that the name is set
        self.assertEqual(coverage.name(), "XML")

        # By construction, each file has the same set
        # of covered/uncovered lines
        self.assertEqual(violations, coverage.violations('file1.py'))
        self.assertEqual(measured, coverage.measured_lines('file1.py'))

        # Try getting a smaller range
        result = coverage.violations('subdir/file2.py')
        self.assertEqual(result, violations)

        # Once more on the first file (for caching)
        result = coverage.violations('file1.py')
        self.assertEqual(result, violations)
开发者ID:Julian,项目名称:diff-cover,代码行数:28,代码来源:test_violations_reporter.py

示例2: test_different_files_in_inputs

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_different_files_in_inputs(self):

        # Construct the XML report
        xml_roots = [
            self._coverage_xml(['file.py'], self.MANY_VIOLATIONS, self.FEW_MEASURED),
            self._coverage_xml(['other_file.py'], self.FEW_VIOLATIONS, self.MANY_MEASURED)
        ]

        # Parse the report
        coverage = XmlCoverageReporter(xml_roots)

        self.assertEqual(self.MANY_VIOLATIONS, coverage.violations('file.py'))
        self.assertEqual(self.FEW_VIOLATIONS, coverage.violations('other_file.py'))
开发者ID:Julian,项目名称:diff-cover,代码行数:15,代码来源:test_violations_reporter.py

示例3: test_two_inputs_second_violate

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_two_inputs_second_violate(self):

        # Construct the XML report
        file_paths = ['file1.py']

        violations1 = self.MANY_VIOLATIONS
        violations2 = self.FEW_VIOLATIONS

        measured1 = self.FEW_MEASURED
        measured2 = self.MANY_MEASURED

        xml = self._coverage_xml(file_paths, violations1, measured1)
        xml2 = self._coverage_xml(file_paths, violations2, measured2)

        # Parse the report
        coverage = XmlCoverageReporter([xml2, xml])

        # By construction, each file has the same set
        # of covered/uncovered lines
        self.assertEqual(
            violations1 & violations2,
            coverage.violations('file1.py')
        )

        self.assertEqual(
            measured1 | measured2,
            coverage.measured_lines('file1.py')
        )
开发者ID:Julian,项目名称:diff-cover,代码行数:30,代码来源:test_violations_reporter.py

示例4: test_empty_violations

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_empty_violations(self):
        """
        Test that an empty violations report is handled properly
        """

        # Construct the XML report
        file_paths = ['file1.py']

        violations1 = self.MANY_VIOLATIONS
        violations2 = set()

        measured1 = self.FEW_MEASURED
        measured2 = self.MANY_MEASURED

        xml = self._coverage_xml(file_paths, violations1, measured1)
        xml2 = self._coverage_xml(file_paths, violations2, measured2)

        # Parse the report
        coverage = XmlCoverageReporter([xml2, xml])

        # By construction, each file has the same set
        # of covered/uncovered lines
        self.assertEqual(
            violations1 & violations2,
            coverage.violations('file1.py')
        )

        self.assertEqual(
            measured1 | measured2,
            coverage.measured_lines('file1.py')
        )
开发者ID:Julian,项目名称:diff-cover,代码行数:33,代码来源:test_violations_reporter.py

示例5: test_three_inputs

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_three_inputs(self):

        # Construct the XML report
        name = "subdir/coverage.xml"
        file_paths = ['file1.py']

        violations1 = self.MANY_VIOLATIONS
        violations2 = self.FEW_VIOLATIONS
        violations3 = self.ONE_VIOLATION

        measured1 = self.FEW_MEASURED
        measured2 = self.MANY_MEASURED
        measured3 = self.VERY_MANY_MEASURED

        xml = self._coverage_xml(file_paths, violations1, measured1)
        xml2 = self._coverage_xml(file_paths, violations2, measured2)
        xml3 = self._coverage_xml(file_paths, violations3, measured3)

        # Parse the report
        coverage = XmlCoverageReporter([xml2, xml, xml3], name)

        # By construction, each file has the same set
        # of covered/uncovered lines
        self.assertEqual(violations1 & violations2 & violations3, coverage.violations('file1.py'))
        self.assertEqual(measured1 | measured2 | measured3, coverage.measured_lines('file1.py'))
开发者ID:avontd2868,项目名称:diff-cover,代码行数:27,代码来源:test_violations_reporter.py

示例6: test_no_such_file

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_no_such_file(self):

        # Construct the XML report with no source files
        xml = self._coverage_xml([], [], [])

        # Parse the report
        coverage = XmlCoverageReporter(xml)

        # Expect that we get no results
        result = coverage.violations('file.py')
        self.assertEqual(result, set([]))
开发者ID:Julian,项目名称:diff-cover,代码行数:13,代码来源:test_violations_reporter.py

示例7: test_non_python_violations

# 需要导入模块: from diff_cover.violations_reporter import XmlCoverageReporter [as 别名]
# 或者: from diff_cover.violations_reporter.XmlCoverageReporter import violations [as 别名]
    def test_non_python_violations(self):
        """
        Non python projects often just have a file name specified while
         the full path can be acquired from a sources tag in the XML.

         This test checks that flow by requesting violation info from a path
         that can only be constructed by using the path provided in the sources
         tag
        """
        fancy_path = 'superFancyPath'
        file_paths = ['file1.java']
        source_paths = [fancy_path]
        violations = self.MANY_VIOLATIONS
        measured = self.FEW_MEASURED

        xml = self._coverage_xml(
            file_paths,
            violations,
            measured,
            source_paths=source_paths
        )
        coverage = XmlCoverageReporter([xml])

        self.assertEqual(
            violations,
            coverage.violations(
                '{0}/{1}'.format(fancy_path, file_paths[0])
            )
        )

        self.assertEqual(
            measured,
            coverage.measured_lines(
                '{0}/{1}'.format(fancy_path, file_paths[0])
            )
        )
开发者ID:mblayman,项目名称:diff-cover,代码行数:38,代码来源:test_violations_reporter.py


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