43
43
if get_log_verbose():
44
44
logging.getLogger().log(level, message)
46
def _log_details(self, level, details):
46
def _log_details(self, level, test):
47
47
"""Log the relavent test details."""
49
for detail in details:
50
# Skip the test-log as it was logged while the test executed
51
if detail == "test-log":
53
detail_content = details[detail]
54
if detail_content.content_type.type == "text":
55
text = "%s: {{{\n%s}}}" % (detail, detail_content.as_text())
57
text = "Binary attachment: \"%s\" (%s)" % (
59
detail_content.content_type
61
self._log(level, text)
48
if hasattr(test, "getDetails"):
49
details = test.getDetails()
50
for detail in details:
51
# Skip the test-log as it was logged while the test executed
52
if detail == "test-log":
54
detail_content = details[detail]
55
if detail_content.content_type.type == "text":
56
text = "%s: {{{\n%s}}}" % (
58
detail_content.as_text()
61
text = "Binary attachment: \"%s\" (%s)" % (
63
detail_content.content_type
65
self._log(level, text)
63
67
def addSuccess(self, test, details=None):
64
68
self._log(logging.INFO, "OK: %s" % (test.id()))
65
return super(LoggedTestResultDecorator, self).addSuccess(test, details)
69
return super().addSuccess(test, details)
67
71
def addError(self, test, err=None, details=None):
68
72
self._log(logging.ERROR, "ERROR: %s" % (test.id()))
69
if hasattr(test, "getDetails"):
70
self._log_details(logging.ERROR, test.getDetails())
71
return super(type(self), self).addError(test, err, details)
73
self._log_details(logging.ERROR, test)
74
return super().addError(test, err, details)
73
76
def addFailure(self, test, err=None, details=None):
74
77
"""Called for a test which failed an assert."""
75
78
self._log(logging.ERROR, "FAIL: %s" % (test.id()))
76
if hasattr(test, "getDetails"):
77
self._log_details(logging.ERROR, test.getDetails())
78
return super(type(self), self).addFailure(test, err, details)
79
self._log_details(logging.ERROR, test)
80
return super().addFailure(test, err, details)
80
82
def addSkip(self, test, reason=None, details=None):
81
83
self._log(logging.INFO, "SKIP: %s" % test.id())
84
86
def addUnexpectedSuccess(self, test, details=None):
85
87
self._log(logging.ERROR, "UNEXPECTED SUCCESS: %s" % test.id())
86
if hasattr(test, "getDetails"):
87
self._log_details(logging.ERROR, test.getDetails())
88
self._log_details(logging.ERROR, test)
88
89
return super().addUnexpectedSuccess(test, details)
90
91
def addExpectedFailure(self, test, err=None, details=None):