jenkins-bot merged this change.

View Change

Approvals: D3r1ck01: Looks good to me, approved jenkins-bot: Verified
[tests] deprecate allowed_failure and allowed_failure_if

Also use unittest.expectedFailure in favour of the wrapper function
for Python 2 because TestResult.wasSuccessful() count usexprected success
as a successful test.

Bug: T223030
Change-Id: I18de0bc29d0506bdb447085c30e2a4fca4136608
---
M tests/utils.py
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/utils.py b/tests/utils.py
index 3b69183..f27b298 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -36,6 +36,7 @@
from pywikibot.data.api import Request as _original_Request
from pywikibot.site import Namespace
from pywikibot.tools import (
+ deprecated,
PY2, PYTHON_VERSION,
UnicodeType as unicode,
)
@@ -70,6 +71,7 @@
return lambda orig: orig


+@deprecated('unittest.expectedFailure', since='20190512')
def allowed_failure(func):
"""
Unit test decorator to allow failure.
@@ -96,9 +98,14 @@
pywikibot.exception(tb=True)
raise unittest.SkipTest('Test is allowed to fail.')
wrapper.__name__ = func.__name__
- return wrapper
+
+ if PY2:
+ return unittest.expectedFailure(func)
+ else:
+ return wrapper


+@deprecated('expected_failure_if', since='20190512')
def allowed_failure_if(expect):
"""
Unit test decorator to allow failure under conditions.

To view, visit change 509620. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I18de0bc29d0506bdb447085c30e2a4fca4136608
Gerrit-Change-Number: 509620
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)