本文整理汇总了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'))
示例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)
示例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)
示例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)