jenkins-bot has submitted this change and it was merged.

Change subject: Allow unexpectedSuccess and expectedFailure
......................................................................


Allow unexpectedSuccess and expectedFailure

Python 3.4, and unittest2 0.8, error on unexpected successes
and warn on expected failure, if those conditions are not handled.

As these are used in pywikibot tests to capture current (usually wrong)
behaviour, and unexpected successes may be due to varying data and even
execution time in the case of script tests, it is not desirable
to fail the build as a consequence.  They need to be investigated
by a human to determine why the behaviour changed.

One way to handle them is to add hooks on the TestCase subclass,
_addUnexpectedSuccess and _addExpectedFailure.  This patch uses
that approach, reporting to stdout 'unexpected success' and
'expected failure', and marks the test as a success.  This closely
resembles the behaviour in Python 2.7, 3.3 and unittest2 0.6.

Change-Id: I8468cb4507414d55f38ec1f73beda311029f4f44
---
M tests/aspects.py
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, but someone else must approve
  XZise: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/aspects.py b/tests/aspects.py
index 00ee838..4aad55e 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -78,6 +78,18 @@
             """
             return self.assertItemsEqual(*args, **kwargs)
 
+    def _addUnexpectedSuccess(self, result):
+        """Report and ignore."""
+        print(' unexpected success ', end='')
+        sys.stdout.flush()
+        result.addSuccess(self)
+
+    def _addExpectedFailure(self, result, exc_info=None):
+        """Report and ignore."""
+        print(' expected failure ', end='')
+        sys.stdout.flush()
+        result.addSuccess(self)
+
     def assertPageInNamespaces(self, page, namespaces):
         """
         Assert that Pages is in namespaces.

-- 
To view, visit https://gerrit.wikimedia.org/r/175329
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8468cb4507414d55f38ec1f73beda311029f4f44
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to