I'm trying to understand how the test suite is architected and not getting very far. Logically what I want is some sort of APISite mock. Looking at the existing core/tests/site_tests.py, it looks like I need to subclass PatchingTestCase, similar to TestRollbackPage. But, when I do that:
> class TestGetParsedPage(PatchingTestCase):
>
> """Test get_parsed_page() site method."""
>
> family = 'wikipedia'
> code = 'test'
> login = True
>
> @staticmethod
> @PatchingTestCase.patched(pywikibot.data.api.Request, '_simulate')
> def _simulate(self, action):
> """Patch api.Request._simulate. Note: self is the Request instance."""
> if action == 'rollback':
> result = {
> 'title': self._params['title'][0].title(),
> 'summary': self._params.get('summary',
> ['Rollback simulation'])[0],
> 'last_revid': 381070,
> }
> return {action: result}
>
> if action and config.simulate and self.write:
> result = {'result': 'Success', 'nochange': ''}
> return {action: result}
>
> return None
>
> @classmethod
> def setUpClass(cls):
> """Use sandbox page for tests."""
> super().setUpClass()
> cls.page = pywikibot.Page(cls.site, 'Sandbox')
>
> def setUp(self):
> """Patch has_right method."""
> super().setUp()
> self.patch(self.site, 'has_right', lambda right: True)
>
> def test_get_with_default_parser(self):
> self.assertIsNotEmpty(self.page.title)
I don't even get as far as the test failing. It's just skipped:
> Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=/Users/roysmith/dev/pywikibot', '/Users/roysmith/dev/pywikibot/core/tests/site_tests.py::TestGetParsedPage::test_get_with_default_parser']
> ============================= test session starts ==============================
> platform darwin -- Python 3.11.8, pytest-9.0.3, pluggy-1.6.0
> rootdir: /Users/roysmith/dev/pywikibot
> configfile: core/tox.ini
> collected 1 item
>
> core/tests/site_tests.py s [100%]
>
> ============================== 1 skipped in 0.98s ==============================
> Finished running tests!
> On Apr 15, 2026, at 8:27 PM, Huji Lee <huji.huji(a)gmail.com> wrote:
>
> Welcome, Roy!
>
> I don't contribute to pwb frequently anymore, which is why I haven't kept my local testing config up to date and am relying on the CI on Gerrit. However, if you intend to contribute regularly (say, once a month or more) then I recommend you get the local testing to work for you. And if some tests are problematic, please feel free to help enhance them.