jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831184 )
Change subject: [tess] use utils.skipping for several tests ......................................................................
[tess] use utils.skipping for several tests
Change-Id: Id2494034e4616b9d76274e5ca5fe66cfefdd6063 --- M tests/edit_failure_tests.py M tests/eventstreams_tests.py M tests/pagegenerators_tests.py M tests/site_detect_tests.py 4 files changed, 10 insertions(+), 17 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py index 80e4fc5..6ffb497 100755 --- a/tests/edit_failure_tests.py +++ b/tests/edit_failure_tests.py @@ -30,6 +30,7 @@ TitleblacklistError, ) from tests.aspects import TestCase, WikibaseTestCase +from tests.utils import skipping
class TestSaveFailure(TestCase): @@ -55,13 +56,9 @@ """Test that spam in content raise the appropriate exception.""" page = pywikibot.Page(self.site, 'Wikipedia:Sandbox') page.text = 'http://badsite.com' - try: - with self.assertRaisesRegex( - SpamblacklistError, - 'badsite.com'): - page.save() - except OtherPageSaveError as e: - self.skipTest(e) + with skipping(OtherPageSaveError), self.assertRaisesRegex( + SpamblacklistError, 'badsite.com'): + page.save()
def test_titleblacklist(self): """Test that title blacklist raise the appropriate exception.""" diff --git a/tests/eventstreams_tests.py b/tests/eventstreams_tests.py index b09f5c0..873bfc7 100755 --- a/tests/eventstreams_tests.py +++ b/tests/eventstreams_tests.py @@ -16,6 +16,7 @@ from pywikibot.tools import PYTHON_VERSION
from tests.aspects import DefaultSiteTestCase, TestCase, require_modules +from tests.utils import skipping
@mock.patch('pywikibot.comms.eventstreams.EventSource', new=mock.MagicMock()) @@ -309,10 +310,8 @@ ValueError 'Unterminated string' when json.load is processed if the limit is high enough. """ - try: + with skipping(NotImplementedError): self.es = EventStreamsTestClass(streams='recentchange') - except NotImplementedError as e: - self.skipTest(e) limit = 50 self.es.set_maximum_items(limit) self.assertLength(list(self.es), limit) diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index 58df3a2..37f9cce 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -36,6 +36,7 @@ WikidataTestCase, ) from tests.tools_tests import GeneratorIntersectTestCase +from tests.utils import skipping
en_wp_page_titles = ( @@ -376,12 +377,10 @@ site = self.get_site() gen = pagegenerators.PetScanPageGenerator(['Pywikibot Protect Test'], True, None, site) - try: + with skipping(ServerError): self.assertPageTitlesEqual(gen, titles=( 'User:Sn1per/ProtectTest1', 'User:Sn1per/ProtectTest2'), site=site) - except ServerError as e: - self.skipTest(e)
gen = pagegenerators.PetScanPageGenerator(['Pywikibot Protect Test'], False, None, site) diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py index 36caffa..2ac6ffc 100755 --- a/tests/site_detect_tests.py +++ b/tests/site_detect_tests.py @@ -17,7 +17,7 @@ from pywikibot.site_detect import MWSite from tests import unittest_print from tests.aspects import PatchingTestCase, TestCase -from tests.utils import DrySite +from tests.utils import DrySite, skipping
class SiteDetectionTestCase(TestCase): @@ -33,10 +33,8 @@ :param url: Url of tested site :raises AssertionError: Site under url is not MediaWiki powered """ - try: + with skipping(ServerError, requests_exceptions.Timeout): self.assertIsInstance(MWSite(url), MWSite) - except (ServerError, requests_exceptions.Timeout) as e: - self.skipTest(e)
def assertNoSite(self, url: str): """
pywikibot-commits@lists.wikimedia.org