jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509620 )
Change subject: [tests] deprecate allowed_failure and allowed_failure_if
......................................................................
[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(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
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 https://gerrit.wikimedia.org/r/509620
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: I18de0bc29d0506bdb447085c30e2a4fca4136608
Gerrit-Change-Number: 509620
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509621 )
Change subject: [tests] Remove TestPageAssert from tests_tests.py
......................................................................
[tests] Remove TestPageAssert from tests_tests.py
TestPageAssert is not a real test. It only shows the behavior
if two lists are compared.
Bug: T223030
Change-Id: I407e98fed8b1bb54065012f88e2ec286ad44d325
---
M tests/tests_tests.py
1 file changed, 0 insertions(+), 22 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/tests_tests.py b/tests/tests_tests.py
index 4114a09..9dfc32d 100755
--- a/tests/tests_tests.py
+++ b/tests/tests_tests.py
@@ -7,10 +7,7 @@
# Distributed under the terms of the MIT license.
from __future__ import absolute_import, division, unicode_literals
-import pywikibot
-
from tests.aspects import unittest, TestCase
-from tests.utils import allowed_failure
class HttpServerProblemTestCase(TestCase):
@@ -26,25 +23,6 @@
def test_502(self):
"""Test a HTTP 502 response using http://httpbin.org/status/502."""
self.fail('The test framework should skip this test.')
- pass
-
-
-class TestPageAssert(TestCase):
-
- """Test page assertion methods."""
-
- family = 'wikipedia'
- code = 'en'
-
- dry = True
-
- @allowed_failure
- def test_assertPageTitlesEqual(self):
- """Test assertPageTitlesEqual shows the second page title and '...'."""
- pages = [pywikibot.Page(self.site, 'Foo'),
- pywikibot.Page(self.site, 'Bar'),
- pywikibot.Page(self.site, 'Baz')]
- self.assertPageTitlesEqual(pages, ['Foo'], self.site)
class TestLengthAssert(TestCase):
--
To view, visit https://gerrit.wikimedia.org/r/509621
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: I407e98fed8b1bb54065012f88e2ec286ad44d325
Gerrit-Change-Number: 509621
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509635 )
Change subject: [cleanup] expectedFailure is not counted as failing test
......................................................................
[cleanup] expectedFailure is not counted as failing test
expectedFailure is not counted as failing test but listed separately
by default. Restore the default behavior.
Change-Id: I2f95448fab6fe8e09e236ddb45920f0cd6c2e8ad
---
M tests/aspects.py
1 file changed, 0 insertions(+), 6 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 71f14e6..05fe85f 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -132,12 +132,6 @@
sys.stdout.flush()
result.addSuccess(self)
- def _addExpectedFailure(self, result, exc_info=None):
- """Report and ignore."""
- unittest_print(' expected failure ', end='')
- sys.stdout.flush()
- result.addSuccess(self)
-
def assertMethod(self, method, *args):
"""Generic method assertion."""
if not method(*args):
--
To view, visit https://gerrit.wikimedia.org/r/509635
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: I2f95448fab6fe8e09e236ddb45920f0cd6c2e8ad
Gerrit-Change-Number: 509635
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509132 )
Change subject: [tests] Test whether sseclient.EventSource works as expected
......................................................................
[tests] Test whether sseclient.EventSource works as expected
As found in sseclient 0.0.24 the EventSource gives randomly a
ValueError 'Unterminated string' when json.load is processed
if the limit is high enough.
Bug: T222885
Change-Id: I082a63180eb26b02bb19b53b12490bd137e322a5
---
M tests/eventstreams_tests.py
1 file changed, 50 insertions(+), 1 deletion(-)
Approvals:
Zhuyifei1999: Looks good to me, but someone else must approve
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/eventstreams_tests.py b/tests/eventstreams_tests.py
index 4007e97..5df0a45 100644
--- a/tests/eventstreams_tests.py
+++ b/tests/eventstreams_tests.py
@@ -7,9 +7,11 @@
#
from __future__ import absolute_import, division, unicode_literals
+import json
+
from tests import mock
-from pywikibot.comms.eventstreams import EventStreams
+from pywikibot.comms.eventstreams import EventStreams, EventSource
from pywikibot import config
from pywikibot.family import WikimediaFamily
@@ -248,6 +250,53 @@
self._test_filter(none_type, all_type, any_type, result)
+class EventStreamsTestClass(EventStreams):
+
+ """Test class of EventStreams."""
+
+ def __iter__(self):
+ """Iterator."""
+ n = 0
+ while self._total is None or n < self._total:
+ if not hasattr(self, 'source'):
+ self.source = EventSource(**self.sse_kwargs)
+ event = next(self.source)
+ if event.event == 'message':
+ if not event.data:
+ continue
+ n += 1
+ try:
+ element = json.loads(event.data)
+ except ValueError as e:
+ self.source.resp.close() # close SSLSocket
+ del self.source
+ raise ValueError(
+ '{error}\n\nEvent no {number}: '
+ 'Could not load json data from source\n${event}$'
+ .format(number=n, event=event, error=e))
+ yield element
+ del self.source
+
+
+class TestEventSource(TestCase):
+
+ """Test sseclient.EventSource."""
+
+ net = True
+
+ def test_stream(self):
+ """Verify that the EventSource delivers events without problems.
+
+ As found in sseclient 0.0.24 the EventSource gives randomly a
+ ValueError 'Unterminated string' when json.load is processed
+ if the limit is high enough.
+ """
+ limit = 50
+ self.es = EventStreamsTestClass(streams='recentchange')
+ self.es.set_maximum_items(limit)
+ self.assertLength(list(self.es), limit)
+
+
if __name__ == '__main__': # pragma: no cover
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/509132
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: I082a63180eb26b02bb19b53b12490bd137e322a5
Gerrit-Change-Number: 509132
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)