Python: PyUnit will identify more results and work with real PyUnit

This commit is contained in:
Sebastian Serth
2020-05-04 23:14:20 +02:00
parent f5da2f6995
commit cb3eece863

View File

@ -2,8 +2,7 @@ class PyUnitAdapter < TestingFrameworkAdapter
COUNT_REGEXP = /Ran (\d+) test/
FAILURES_REGEXP = /FAILED \(.*failures=(\d+).*\)/
ERRORS_REGEXP = /FAILED \(.*errors=(\d+).*\)/
# The regex below also catches new line separators.
ASSERTION_ERROR_REGEXP = /AssertionError:\s(.*?)\s\s----------------------------------------------------------------------/m
ASSERTION_ERROR_REGEXP = /^(ERROR|FAIL):\ (.*?)\ .*?^[^\.\n]*?(Error|Exception):\s((\s|\S)*?)(>>>.*?)*\s\s(-|=){70}/m
def self.framework_name
'PyUnit'
@ -15,7 +14,16 @@ class PyUnitAdapter < TestingFrameworkAdapter
failed = failures_matches ? failures_matches.captures.try(:first).to_i : 0
error_matches = ERRORS_REGEXP.match(output[:stderr])
errors = error_matches ? error_matches.captures.try(:first).to_i : 0
assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).flatten || []
assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).map { |match|
testname = match[1]
error = match[3].strip
if testname == 'test_assess'
error
else
"#{testname}: #{error}"
end
}.flatten || []
{count: count, failed: failed + errors, error_messages: assertion_error_matches}
end
end