jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] allowed_failure: Only print relevant stack
......................................................................
[FEAT] allowed_failure: Only print relevant stack
Instead of printing the complete stack it now only prints the stack up
until the 'assert[A-Z]' which is part of unittest. To avoid problems
with non-assertions normal exceptions still use the current output.
Change-Id: I7a2d9a8706eaac8bba5fa9c7a825893838d2a2aa
---
M tests/utils.py
1 file changed, 11 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/utils.py b/tests/utils.py
index ae80633..c736f45 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -9,9 +9,11 @@
__version__ = '$Id$'
#
import os
+import re
import subprocess
import sys
import time
+import traceback
from warnings import warn
@@ -65,9 +67,17 @@
def wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
+ except AssertionError:
+ tb = traceback.extract_tb(sys.exc_info()[2])
+ for depth, line in enumerate(tb):
+ if re.match('^assert[A-Z]', line[2]):
+ break
+ tb = traceback.format_list(tb[:depth])
+ pywikibot.error('\n' + ''.join(tb)[:-1]) # remove \n at the
end
+ raise unittest.SkipTest('Test is allowed to fail.')
except Exception:
pywikibot.exception(tb=True)
- raise unittest.SkipTest()
+ raise unittest.SkipTest('Test is allowed to fail.')
wrapper.__name__ = func.__name__
return wrapper
--
To view, visit
https://gerrit.wikimedia.org/r/202010
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7a2d9a8706eaac8bba5fa9c7a825893838d2a2aa
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>