Sort test messages for deterministic output. (#22581)

This commit is contained in:
Matt Clay 2017-03-13 20:45:10 -07:00 committed by GitHub
parent 07674a8446
commit 771b14acb2

View file

@ -191,12 +191,15 @@ class TestFailure(TestResult):
""" """
:type command: str :type command: str
:type test: str :type test: str
:type python_version: str :type python_version: str | None
:type messages: list[TestMessage] :type messages: list[TestMessage] | None
:type summary: str :type summary: str | None
""" """
super(TestFailure, self).__init__(command, test, python_version) super(TestFailure, self).__init__(command, test, python_version)
if messages:
messages = sorted(messages, key=lambda m: m.sort_key)
self.messages = messages self.messages = messages
self.summary = summary self.summary = summary
@ -338,3 +341,10 @@ class TestMessage(object):
msg = self.message msg = self.message
return '%s:%s:%s: %s' % (self.path, self.line, self.column, msg) return '%s:%s:%s: %s' % (self.path, self.line, self.column, msg)
@property
def sort_key(self):
"""
:rtype: str
"""
return '%s:%6d:%6d:%s:%s' % (self.path, self.line, self.column, self.code or '', self.message)