本文整理汇总了Python中diff_cover.violations_reporter.PylintQualityReporter.name方法的典型用法代码示例。如果您正苦于以下问题:Python PylintQualityReporter.name方法的具体用法?Python PylintQualityReporter.name怎么用?Python PylintQualityReporter.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diff_cover.violations_reporter.PylintQualityReporter
的用法示例。
在下文中一共展示了PylintQualityReporter.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_quality
# 需要导入模块: from diff_cover.violations_reporter import PylintQualityReporter [as 别名]
# 或者: from diff_cover.violations_reporter.PylintQualityReporter import name [as 别名]
def test_quality(self):
# Patch the output of `pylint`
_mock_communicate = patch.object(Popen, 'communicate').start()
_mock_communicate.return_value = (
dedent("""
file1.py:1: [C0111] Missing docstring
file1.py:1: [C0111, func_1] Missing docstring
file1.py:2: [W0612, cls_name.func] Unused variable 'd'
file1.py:2: [W0511] TODO: Not the real way we'll store usages!
file1.py:579: [F0401] Unable to import 'rooted_paths'
file1.py:113: [W0613, cache_relation.clear_pk] Unused argument 'cls'
file1.py:150: [F0010] error while code parsing ([Errno 2] No such file or directory)
file1.py:149: [C0324, Foo.__dict__] Comma not followed by a space
self.peer_grading._find_corresponding_module_for_location(Location('i4x','a','b','c','d'))
file1.py:162: [R0801] Similar lines in 2 files
==external_auth.views:1
==student.views:4
import json
import logging
import random
path/to/file2.py:100: [W0212, openid_login_complete] Access to a protected member
""").strip(), ''
)
expected_violations = [
Violation(1, 'C0111: Missing docstring'),
Violation(1, 'C0111: func_1: Missing docstring'),
Violation(2, "W0612: cls_name.func: Unused variable 'd'"),
Violation(2, "W0511: TODO: Not the real way we'll store usages!"),
Violation(579, "F0401: Unable to import 'rooted_paths'"),
Violation(150, "F0010: error while code parsing ([Errno 2] No such file or directory)"),
Violation(149, "C0324: Foo.__dict__: Comma not followed by a space"),
Violation(162, "R0801: Similar lines in 2 files"),
Violation(113, "W0613: cache_relation.clear_pk: Unused argument 'cls'")
]
# Parse the report
quality = PylintQualityReporter('pylint', [])
# Expect that the name is set
self.assertEqual(quality.name(), 'pylint')
# Measured_lines is undefined for a
# quality reporter since all lines are measured
self.assertEqual(quality.measured_lines('file1.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('file1.py')
self.assertEqual(len(actual_violations), len(expected_violations))
for expected in expected_violations:
self.assertIn(expected, actual_violations)
示例2: test_quality_error
# 需要导入模块: from diff_cover.violations_reporter import PylintQualityReporter [as 别名]
# 或者: from diff_cover.violations_reporter.PylintQualityReporter import name [as 别名]
def test_quality_error(self):
# Patch the output of `pylint`
_mock_communicate = patch.object(Popen, 'communicate').start()
_mock_communicate.return_value = ("", 'whoops')
name = "pylint"
# Parse the report
quality = PylintQualityReporter(name)
# Expect that the name is set
self.assertEqual(quality.name(), name)
self.assertRaises(QualityReporterError, quality.violations, 'file1.py')
示例3: test_quality
# 需要导入模块: from diff_cover.violations_reporter import PylintQualityReporter [as 别名]
# 或者: from diff_cover.violations_reporter.PylintQualityReporter import name [as 别名]
def test_quality(self):
# Patch the output of `pylint`
_mock_communicate = patch.object(Popen, 'communicate').start()
_mock_communicate.return_value = ("************* Module new_file\nC0111: 1,0: Missing docstring\ndef func_1(apple,my_list):\n ^^\nC0111: 1,0:func_1: Missing docstring\n\nW0612: 2,4:func_1: Unused variable 'd'", '')
violations = [Violation(1, 'C0111: Missing docstring'), Violation(1, 'C0111: Missing docstring'), Violation(2, "W0612: Unused variable 'd'")]
name = "pylint"
# Parse the report
quality = PylintQualityReporter(name)
# Expect that the name is set
self.assertEqual(quality.name(), name)
# measured_lines is undefined for a quality reporter since all lines are measured
self.assertEqual(quality.measured_lines('file1.py'), None)
# By construction, each file has the same set
# of covered/uncovered lines
self.assertEqual(violations, quality.violations('file1.py'))