本文整理汇总了Python中diff_cover.violationsreporters.base.QualityReporter.violations方法的典型用法代码示例。如果您正苦于以下问题:Python QualityReporter.violations方法的具体用法?Python QualityReporter.violations怎么用?Python QualityReporter.violations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diff_cover.violationsreporters.base.QualityReporter
的用法示例。
在下文中一共展示了QualityReporter.violations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_quality_reporter
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_quality_reporter(self, mock_stderr):
with patch('diff_cover.violationsreporters.base.run_command_for_code') as code:
code.return_value = 0
reporter = QualityReporter(pep8_driver)
with self.assertRaises(OSError):
reporter.violations("path/to/file.py")
self.assertEqual(mock_stderr.getvalue(), "pep8 path/to/file.py")
示例2: test_quality_error
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_quality_error(self):
_setup_patch((b"", 'whoops Ƕئ'.encode('utf-8')), status_code=1)
# Parse the report
quality = QualityReporter(self._get_out())
# Expect that the name is set
self.assertEqual(quality.name(), self.quality_name)
with self.assertRaises(CommandError) as ex:
quality.violations('file1.js')
self.assertEqual(six.text_type(ex.exception), 'whoops Ƕئ')
示例3: test_quality_error
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_quality_error(self):
_patch_so_all_files_exist()
_setup_patch((b"", 'whoops Ƕئ'.encode('utf-8')), status_code=1)
with patch('diff_cover.violationsreporters.base.run_command_for_code') as code:
code.return_value = 0
# Parse the report
quality = QualityReporter(self._get_out())
# Expect that the name is set
self.assertEqual(quality.name(), self.quality_name)
with self.assertRaises(CommandError) as ex:
quality.violations('file1.js')
self.assertEqual(six.text_type(ex.exception), 'whoops Ƕئ')
示例4: test_file_does_not_exist
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_file_does_not_exist(self):
quality = QualityReporter(flake8_driver)
file_paths = ['ajshdjlasdhajksdh.py']
# Expect that we get no results because that file does not exist
for path in file_paths:
result = quality.violations(path)
self.assertEqual(result, [])
示例5: test_no_quality_issues_emptystring
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_quality_issues_emptystring(self):
# Patch the output of `pyflakes`
_setup_patch((b'', b''))
# Parse the report
quality = QualityReporter(pyflakes_driver)
self.assertEqual([], quality.violations('file1.py'))
示例6: test_no_java_file
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_java_file(self):
quality = QualityReporter(FindbugsXmlDriver())
file_paths = ['file1.coffee', 'subdir/file2.js']
# Expect that we get no results because no Java files
for path in file_paths:
result = quality.violations(path)
self.assertEqual(result, [])
示例7: test_no_python_file
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_python_file(self):
"""Expect that we get no results because no Python files."""
quality = QualityReporter(pydocstyle_driver)
file_paths = ['file1.coffee', 'subdir/file2.js']
for path in file_paths:
result = quality.violations(path)
self.assertEqual(result, [])
示例8: test_quality
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [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)
示例9: test_no_js_file
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_js_file(self):
quality = QualityReporter(self._get_out())
file_paths = ['file1.py', 'subdir/file2.java']
# Expect that we get no results because no JS files
for path in file_paths:
result = quality.violations(path)
self.assertEqual(result, [])
示例10: test_quality
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [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'))
示例11: test_no_python_file
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_python_file(self):
quality = QualityReporter(PylintDriver())
file_paths = ['file1.coffee', 'subdir/file2.js']
# Expect that we get no results because no Python files
for path in file_paths:
result = quality.violations(path)
self.assertEqual(result, [])
示例12: test_quality
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [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)
示例13: test_no_quality_issues_newline
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_no_quality_issues_newline(self):
_setup_patch((b'\n', b''), 0)
# Parse the report
quality = QualityReporter(PylintDriver())
self.assertEqual([], quality.violations('file1.py'))
示例14: test_unicode
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_unicode(self):
_mock_communicate = patch.object(Popen, 'communicate').start()
# Test non-ascii unicode characters in the filename, function name and message
_mock_communicate.return_value = (dedent(u"""
file_\u6729.py:616: [W1401] Anomalous backslash in string: '\u5922'. String constant might be missing an r prefix.
file.py:2: [W0612, cls_name.func_\u9492] Unused variable '\u2920'
""").encode('utf-8'), b'')
quality = QualityReporter(PylintDriver())
violations = quality.violations(u'file_\u6729.py')
self.assertEqual(violations, [
Violation(616, u"W1401: Anomalous backslash in string: '\u5922'. String constant might be missing an r prefix."),
])
violations = quality.violations(u'file.py')
self.assertEqual(violations, [Violation(2, u"W0612: cls_name.func_\u9492: Unused variable '\u2920'")])
示例15: test_unicode
# 需要导入模块: from diff_cover.violationsreporters.base import QualityReporter [as 别名]
# 或者: from diff_cover.violationsreporters.base.QualityReporter import violations [as 别名]
def test_unicode(self):
_setup_patch(
(dedent(u"""
file_\u6729.py:616: [W1401] Anomalous backslash in string: '\u5922'. String constant might be missing an r prefix.
file.py:2: [W0612, cls_name.func_\u9492] Unused variable '\u2920'
""").encode('utf-8'),
''),
0
)
quality = QualityReporter(PylintDriver())
violations = quality.violations(u'file_\u6729.py')
self.assertEqual(violations, [
Violation(616, u"W1401: Anomalous backslash in string: '\u5922'. String constant might be missing an r prefix."),
])
violations = quality.violations(u'file.py')
self.assertEqual(violations, [Violation(2, u"W0612: cls_name.func_\u9492: Unused variable '\u2920'")])