jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/566472 )

Change subject: [tests] Remove allowed_failure decorator from utils.py
......................................................................

[tests] Remove allowed_failure decorator from utils.py

With 85b908fa7f8 allowed_failure  isn't used anymore.
That decorator does not support subTest and should be
replaced by expectedFailure or skipTest if necessary.

Bug: T223030
Change-Id: I55f7c2013aa4fd9e78eda701e266c3f93f664357
---
M tests/utils.py
1 file changed, 0 insertions(+), 54 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/utils.py b/tests/utils.py
index f1acc10..cc7db4d 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -7,14 +7,11 @@
 #
 from __future__ import absolute_import, division, unicode_literals

-from functools import wraps
 import inspect
 import json
 import os
-import re
 from subprocess import PIPE, Popen
 import sys
-import traceback
 import warnings

 try:
@@ -72,57 +69,6 @@
         return lambda orig: orig


-def allowed_failure(func):
-    """
-    Unit test decorator to allow failure.
-
-    This decorator runs the test and, if it is an Assertion failure,
-    reports the result and considers it a skipped test. This is a
-    similar behaviour like expectedFailure in Python 2. Passing a test
-    will not count as failure (unexpected success) which Python 3 does.
-
-    This decorator should be used if a test passes or fails due to
-    random test parameters. If tests fails deterministic expectedFailure
-    decorator should be used instead.
-
-    @note: This decorator does not support subTest content manager.
-    """
-    @wraps(func)
-    def wrapper(*args, **kwargs):
-        try:
-            func(*args, **kwargs)
-        except AssertionError:
-            pywikibot.exception(tb=False)
-            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.')
-
-    if PY2:
-        return unittest.expectedFailure(func)
-    else:
-        return wrapper
-
-
-def allowed_failure_if(expect):
-    """
-    Unit test decorator to allow failure under conditions.
-
-    See allowed_failure method for more details.
-
-    @note: This decorator does not support subTest content manager.
-    @param expect: Flag to check if failure is allowed
-    @type expect: bool
-    """
-    if expect:
-        return allowed_failure
-    else:
-        return lambda orig: orig
-
-
 def add_metaclass(cls):
     """Call six's add_metaclass with the site's __metaclass__ in Python 3."""
     if not PY2:

--
To view, visit https://gerrit.wikimedia.org/r/566472
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I55f7c2013aa4fd9e78eda701e266c3f93f664357
Gerrit-Change-Number: 566472
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to