jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1055599?usp=email )
Change subject: [tests] skip connected page within unconnected_pages tests ......................................................................
[tests] skip connected page within unconnected_pages tests
The connection can be established in meantime.
Bug: T370596 Change-Id: I182dd058d36b87ecf5baed1e3721c5b7e6530482 --- M tests/pagegenerators_tests.py M tests/site_generators_tests.py 2 files changed, 29 insertions(+), 7 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index 7efd78f..7d1aaa1 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -28,7 +28,7 @@ WikibaseItemFilterPageGenerator, ) from pywikibot.tools import has_module -from tests import join_data_path +from tests import join_data_path, unittest_print from tests.aspects import ( DefaultSiteTestCase, DeprecationTestCase, @@ -1699,10 +1699,21 @@
pattern = (fr'Page [[({site.sitename}:|{site.code}:)-1]]' r" doesn't exist.") + found = [] for page in pages: - with self.subTest(page=page), self.assertRaisesRegex( - NoPageError, pattern): - page.data_item() + with self.subTest(page=page): + try: + page.data_item() + except NoPageError as e: + self.assertRegex(str(e), pattern) + else: + found.append(page) + if found: + unittest_print('connection found for ', + ', '.join(str(p) for p in found)) + + # assume that we have at least one unconnected page + self.assertLess(len(found), 3)
def test_unconnected_without_repo(self): """Test that it raises a ValueError on sites without repository.""" diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py index 86c98e0..75bd805 100755 --- a/tests/site_generators_tests.py +++ b/tests/site_generators_tests.py @@ -690,10 +690,21 @@
pattern = (fr'Page [[({site.sitename}:|{site.code}:)-1]]' r" doesn't exist.") + found = [] for page in pages: - with self.subTest(page=page), self.assertRaisesRegex( - NoPageError, pattern): - page.data_item() + with self.subTest(page=page): + try: + page.data_item() + except NoPageError as e: + self.assertRegex(str(e), pattern) + else: + found.append(page) + if found: + unittest_print('connection found for ', + ', '.join(str(p) for p in found)) + + # assume that we have at least one unconnected page + self.assertLess(len(found), 3)
class TestSiteGeneratorsUsers(DefaultSiteTestCase):
pywikibot-commits@lists.wikimedia.org