Add PyLint Adapter and a combined PyUnit and PyLint adapter.
This commit is contained in:
21
lib/py_lint_adapter.rb
Normal file
21
lib/py_lint_adapter.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class PyLintAdapter < TestingFrameworkAdapter
|
||||||
|
REGEXP = /Your code has been rated at (\d+\.?\d*)\/(\d+\.?\d*)/
|
||||||
|
ASSERTION_ERROR_REGEXP = /^.*?\(.*?,\ (.*?),.*?\)\ (.*?)$/m
|
||||||
|
|
||||||
|
def self.framework_name
|
||||||
|
'PyLint'
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_output(output)
|
||||||
|
captures = REGEXP.match(output[:stdout]).captures.map(&:to_f)
|
||||||
|
count = captures.second
|
||||||
|
passed = captures.first
|
||||||
|
failed = count - passed
|
||||||
|
assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match|
|
||||||
|
test = match.first.strip
|
||||||
|
description = match.second.strip
|
||||||
|
"#{test}: #{description}"
|
||||||
|
}.flatten || []
|
||||||
|
{count: count, failed: failed, error_messages: assertion_error_matches}
|
||||||
|
end
|
||||||
|
end
|
13
lib/py_unit_and_py_lint_adapter.rb
Normal file
13
lib/py_unit_and_py_lint_adapter.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class PyUnitAndPyLintAdapter < TestingFrameworkAdapter
|
||||||
|
|
||||||
|
def self.framework_name
|
||||||
|
'PyUnit and PyLint'
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_output(output)
|
||||||
|
PyLintAdapter.new.parse_output(output)
|
||||||
|
rescue NoMethodError
|
||||||
|
# The regex for PyLint failed and did not return any matches
|
||||||
|
PyUnitAdapter.new.parse_output(output)
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user