本文整理汇总了Python中diff_cover.violationsreporters.base.QualityReporter类的典型用法代码示例。如果您正苦于以下问题:Python QualityReporter类的具体用法?Python QualityReporter怎么用?Python QualityReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QualityReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_js_file
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, [])
示例2: test_no_python_file
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, [])
示例3: test_quality
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)
示例4: test_no_quality_issues_emptystring
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'))
示例5: test_file_does_not_exist
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, [])
示例6: test_no_java_file
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_quality
def test_quality(self):
# Patch the output of `pep8`
_mock_communicate = patch.object(Popen, 'communicate').start()
return_string = '\n' + dedent("""
../new_file.py:1:17: E231 whitespace
../new_file.py:3:13: E225 whitespace
../new_file.py:7:1: E302 blank lines
""").strip() + '\n'
_mock_communicate.return_value = (
(return_string.encode('utf-8'), b''))
# Parse the report
quality = QualityReporter(pep8_driver)
# Expect that the name is set
self.assertEqual(quality.name(), 'pep8')
# 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(1, 'E231 whitespace'),
Violation(3, 'E225 whitespace'),
Violation(7, 'E302 blank lines')
]
self.assertEqual(expected_violations, quality.violations('../new_file.py'))
示例8: test_no_python_file
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, [])
示例9: test_quality
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)
示例10: test_no_quality_issues_newline
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'))
示例11: test_quality_reporter
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")
示例12: test_no_quality_issues_newline
def test_no_quality_issues_newline(self):
# Patch the output of the linter cmd
self.subproc_mock.communicate.return_value = (b'\n', b'')
self._mock_communicate.return_value = self.subproc_mock
# Parse the report
quality = QualityReporter(self._get_out())
self.assertEqual([], quality.violations('test-file.js'))
示例13: test_no_quality_issues_emptystring
def test_no_quality_issues_emptystring(self):
# Patch the output of `pylint`
_mock_communicate = patch.object(Popen, 'communicate').start()
_mock_communicate.return_value = (b'', b'')
# Parse the report
quality = QualityReporter(PylintDriver())
self.assertEqual([], quality.violations('file1.py'))
示例14: test_unicode_continuation_char
def test_unicode_continuation_char(self):
_setup_patch(
(b"file.py:2: [W1401]"b" Invalid char '\xc3'", ''),
0
)
# Since we are replacing characters we can't interpet, this should
# return a valid string with the char replaced with '?'
quality = QualityReporter(PylintDriver())
violations = quality.violations(u'file.py')
self.assertEqual(violations, [Violation(2, u"W1401: Invalid char '\ufffd'")])
示例15: test_quality_pregenerated_report_continuation_char
def test_quality_pregenerated_report_continuation_char(self):
# The report contains a non-ASCII continuation char
pylint_reports = [BytesIO(b"file.py:2: [W1401] Invalid char '\xc3'")]
# Generate the violation report
quality = QualityReporter(PylintDriver(), reports=pylint_reports)
violations = quality.violations('file.py')
# Expect that the char is replaced
self.assertEqual(violations, [Violation(2, u"W1401: Invalid char '\ufffd'")])