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


Python QualityReporter.measured_lines方法代码示例

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


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

示例1: test_quality

# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import measured_lines [as 别名]
    def test_quality(self):

        # Patch the output of `pyflakes`
        _mock_communicate = patch.object(Popen, 'communicate').start()
        return_string = '\n' + dedent("""
                ../new_file.py:328: undefined name '_thing'
                ../new_file.py:418: 'random' imported but unused
            """).strip() + '\n'
        _mock_communicate.return_value = (
            (return_string.encode('utf-8'), b''))

        # Parse the report
        quality = QualityReporter(pyflakes_driver)

        # Expect that the name is set
        self.assertEqual(quality.name(), 'pyflakes')

        # Measured_lines is undefined for
        # a quality reporter since all lines are measured
        self.assertEqual(quality.measured_lines('../new_file.py'), None)

        # Expect that we get the right violations
        expected_violations = [
            Violation(328, "undefined name '_thing'"),
            Violation(418, "'random' imported but unused")
        ]

        self.assertEqual(
            expected_violations,
            quality.violations('../new_file.py'))
开发者ID:Shoobx,项目名称:diff-cover,代码行数:32,代码来源:test_violations_reporter.py

示例2: test_quality

# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import measured_lines [as 别名]
    def test_quality(self):
        """Integration test."""
        # Patch the output of `pydocstye`
        _setup_patch((
            dedent("""
            ../new_file.py:1 at module level:
                    D100: Missing docstring in public module
            ../new_file.py:13 in public function `gather`:
                    D103: Missing docstring in public function
            """).strip().encode('ascii'), ''
        ))

        expected_violations = [
            Violation(1, 'D100: Missing docstring in public module'),
            Violation(13, "D103: Missing docstring in public function"),
        ]

        # Parse the report
        quality = QualityReporter(pydocstyle_driver)

        # Expect that the name is set
        self.assertEqual(quality.name(), 'pydocstyle')

        # Measured_lines is undefined for a
        # quality reporter since all lines are measured
        self.assertEqual(quality.measured_lines('../new_file.py'), None)

        # Expect that we get violations for file1.py only
        # We're not guaranteed that the violations are returned
        # in any particular order.
        actual_violations = quality.violations('../new_file.py')
        self.assertEqual(len(actual_violations), len(expected_violations))
        for expected in expected_violations:
            self.assertIn(expected, actual_violations)
开发者ID:hugovk,项目名称:diff-cover,代码行数:36,代码来源:test_violations_reporter.py

示例3: test_quality

# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import measured_lines [as 别名]
    def test_quality(self):
        """Integration test."""
        # Patch the output of `checkstyle`
        _setup_patch((
            dedent("""
            [WARN] ../new_file.java:1:1: Line contains a tab character.
            [WARN] ../new_file.java:13: 'if' construct must use '{}'s.
            """).strip().encode('ascii'), ''
        ))

        expected_violations = [
            Violation(1, 'Line contains a tab character.'),
            Violation(13, "'if' construct must use '{}'s."),
        ]

        # Parse the report
        quality = QualityReporter(checkstyle_driver)

        # Expect that the name is set
        self.assertEqual(quality.name(), 'checkstyle')

        # Measured_lines is undefined for a
        # quality reporter since all lines are measured
        self.assertEqual(quality.measured_lines('../new_file.java'), None)

        # Expect that we get violations for file1.java only
        # We're not guaranteed that the violations are returned
        # in any particular order.
        actual_violations = quality.violations('../new_file.java')
        self.assertEqual(len(actual_violations), len(expected_violations))
        for expected in expected_violations:
            self.assertIn(expected, actual_violations)
开发者ID:hugovk,项目名称:diff-cover,代码行数:34,代码来源:test_java_violations_reporter.py

示例4: test_quality_pregenerated_report

# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import measured_lines [as 别名]
    def test_quality_pregenerated_report(self):

        # When the user provides us with a pre-generated linter report
        # then use that instead of calling linter directly.
        reports = [
            BytesIO(('\n' + dedent("""
                path/to/file.js: line 3, col 9, Missing "use strict" statement.
                path/to/file.js: line 10, col 130, Line is too long.
                another/file.js: line 1, col 1, 'require' is not defined.
            """).strip() + '\n').encode('utf-8')),

            BytesIO(('\n' + dedent(u"""
                path/to/file.js: line 12, col 14, \u9134\u1912
                path/to/file.js: line 10, col 17, '$hi' is defined but never used.
            """).strip() + '\n').encode('utf-8')),
        ]

        # Parse the report
        quality = QualityReporter(self._get_out(), reports=reports)

        # Measured_lines is undefined for
        # a quality reporter since all lines are measured
        self.assertEqual(quality.measured_lines('path/to/file.js'), None)

        # Expect that we get the right violations
        expected_violations = [
            Violation(3, u'Missing "use strict" statement.'),
            Violation(10, u"Line is too long."),
            Violation(10, u"'$hi' is defined but never used."),
            Violation(12, u"\u9134\u1912")
        ]

        # We're not guaranteed that the violations are returned
        # in any particular order.
        actual_violations = quality.violations('path/to/file.js')

        self.assertEqual(len(actual_violations), len(expected_violations))
        for expected in expected_violations:
            self.assertIn(expected, actual_violations)
开发者ID:Shoobx,项目名称:diff-cover,代码行数:41,代码来源:test_violations_reporter.py


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