Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a classname of pylint for testcases #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/pylint_junit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def on_set_current_module(self, module, filepath):
if self.current_module is not None and self.items[self.current_module].test_cases is not None:
stdout_line = "All checks passed for: {0}".format(self.current_filepath)
testcase_name = "{0}:0:0".format(self.current_module)
testcase = TestCase(testcase_name, stdout=stdout_line, file=self.current_filepath, line=0)
testcase = TestCase(testcase_name, classname='pylint', stdout=stdout_line, file=self.current_filepath, line=0)
self.items[self.current_module].test_cases.append(testcase)

self.current_module = module
Expand All @@ -39,17 +39,21 @@ def on_close(self, stats, previous_stats):

def handle_message(self, msg):
"""Manage message of different type and in the context of path."""
source_line = getline(msg.path, msg.line).strip().decode('utf-8')
try:
source_line = getline(msg.path, msg.line).strip().decode('utf-8')
except AttributeError:
source_line = getline(msg.path, msg.line).strip()

stdout_line = u"{0}:{1}:{2}:{3}".format(msg.path, msg.line, msg.column, source_line)
stderr_line = u"{0}:{1}\n{2}".format(msg.msg_id, msg.msg, stdout_line)
testcase_name = u"{0}:{1}:{2}".format(msg.module, msg.line, msg.column)
testcase = TestCase(testcase_name, stdout=stdout_line, stderr=stderr_line, file=msg.path, line=msg.line, category=msg.category)
testcase = TestCase(testcase_name, classname='pylint', stdout=stdout_line, stderr=stderr_line, file=msg.path, line=msg.line, category=msg.category)
testcase.add_error_info(message=msg.symbol, output=stderr_line)
self.items[self.current_module].test_cases.append(testcase)

def display_messages(self, layout):
xml_str = TestSuite.to_xml_string(self.items.values())
print(xml_str.encode('utf-8'), file=self.out)
print(xml_str, file=self.out)

def display_reports(self, layout):
"""Don't do nothing in this reporter."""
Expand Down