Skip to content

Commit

Permalink
[tests] skip connected page within unconnected_pages tests
Browse files Browse the repository at this point in the history
The connection can be established in meantime.

Bug: T370596
Change-Id: I182dd058d36b87ecf5baed1e3721c5b7e6530482
  • Loading branch information
xqt committed Jul 21, 2024
1 parent 802d5ce commit 13af587
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
19 changes: 15 additions & 4 deletions tests/pagegenerators_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1699,10 +1699,21 @@ def test_unconnected_with_repo(self):

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."""
Expand Down
17 changes: 14 additions & 3 deletions tests/site_generators_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,21 @@ def test_unconnected(self):

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):
Expand Down

0 comments on commit 13af587

Please sign in to comment.