jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342325 )
Change subject: interwikidata_tests.py: Do not change config while performing tests ......................................................................
interwikidata_tests.py: Do not change config while performing tests
Calling interwikidata.main with `lang` and `family` arguments changes config values.
Instead of calling `main`, call `interwikidata.IWBot` directly. This way we will skip over `pywikibot.handle_args`.
Also use assertRaisesRegex instead of assertRaises.
Bug: T160272 Bug: T154281 Change-Id: I68d9fbbc027416a99c2b9cc777127e35c868d7a8 --- M tests/interwikidata_tests.py 1 file changed, 9 insertions(+), 3 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/tests/interwikidata_tests.py b/tests/interwikidata_tests.py index 2f75a9b..708acd3 100644 --- a/tests/interwikidata_tests.py +++ b/tests/interwikidata_tests.py @@ -93,9 +93,15 @@ wt_page = pywikibot.Page(self.wt, 'User:Ladsgroup') self.assertRaises(ValueError, DummyBot, generator=[wt_page], site=self.wt)
- self.assertRaises(ValueError, interwikidata.main, - '-page:User:Ladsgroup', '-lang:fa', - '-family:wiktionary') + fa_wiktionary = pywikibot.Site('fa', 'wiktionary') + self.assertRaisesRegex( + ValueError, + r'wiktionary:fa does not have a data repository, ' + r'use interwiki.py instead.', + interwikidata.IWBot, + generator=[pywikibot.Page(fa_wiktionary, 'User:Dalba')], + site=fa_wiktionary, + )
if __name__ == '__main__': # pragma: no cover
pywikibot-commits@lists.wikimedia.org