From 380b1a5ba111fc6281dbc8b5cab607a187102ff5 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sat, 24 Oct 2020 16:11:12 +0200 Subject: [PATCH] Get more details from PyLint --- lib/py_lint_adapter.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/py_lint_adapter.rb b/lib/py_lint_adapter.rb index dbe63ea1..5d3ad306 100644 --- a/lib/py_lint_adapter.rb +++ b/lib/py_lint_adapter.rb @@ -1,6 +1,6 @@ class PyLintAdapter < TestingFrameworkAdapter REGEXP = /Your code has been rated at (-?\d+\.?\d*)\/(\d+\.?\d*)/ - ASSERTION_ERROR_REGEXP = /^.*?\([^,]*?,\ ([^,]*?),[^,]*?\)\ (.*?)$/ + ASSERTION_ERROR_REGEXP = /^.*?\.py:(\d+):.*?\([^,]*?,\ ([^,]*?),([^,]*?)\)\ (.*?)$/ def self.framework_name 'PyLint' @@ -21,9 +21,12 @@ class PyLintAdapter < TestingFrameworkAdapter begin assertion_error_matches = Timeout.timeout(2.seconds) do output[:stdout].scan(ASSERTION_ERROR_REGEXP).map do |match| - test = match.first.strip - description = match.second.strip - {test: test, description: description} + line_no = match.first.strip + test = match.second.strip + # e.g. function name, nil if outside of a function. Not always available + context = match.third.strip.presence + description = match.fourth.strip + {test: test, description: description, context: context, line: line_no} end || [] end rescue Timeout::Error