jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/767464 )
Change subject: [cleanup] Remove unused tests parts ......................................................................
[cleanup] Remove unused tests parts
- remove unused bot_tests.FakeSaveBotTestCase - remove unused tests/i18n/pywikibot.py - remove api_tests.TestBadTokenRecovery because not test is made and no log is written due to this test
Change-Id: I316224f415c97928d6485f007ecee54f75c99d64 --- M tests/api_tests.py M tests/bot_tests.py D tests/i18n/pywikibot.py 3 files changed, 0 insertions(+), 100 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/api_tests.py b/tests/api_tests.py index 6d6447d..f9d22c5 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -900,25 +900,6 @@ 'You have no API read permissions. Seems you are not logged in.')
-class TestBadTokenRecovery(TestCase): - - """Test that the request recovers from bad tokens.""" - - family = 'wikipedia' - code = 'test' - - write = True - - def test_bad_token(self): - """Test the bad token recovery by corrupting the cache.""" - site = self.get_site() - site.tokens._tokens.setdefault(site.user(), {})['edit'] = 'INVALID' - page = pywikibot.Page(site, 'Pywikibot bad token test') - page.text = ('This page is testing whether pywikibot rerequests ' - 'a token when a badtoken error was received.') - page.save(summary='Bad token test') - - class TestUrlEncoding(TestCase):
"""Test encode_url() function.""" diff --git a/tests/bot_tests.py b/tests/bot_tests.py index c06cee0..12c89de 100644 --- a/tests/bot_tests.py +++ b/tests/bot_tests.py @@ -32,80 +32,6 @@ super().setUpClass()
-class FakeSaveBotTestCase(TestCase): - - """ - An abstract test case which patches the bot class to not actually write. - - It redirects the bot's _save_page to it's own ``bot_save`` method. - Currently userPut, put_current and user_edit_entity call it. By - default it'll call the original method but replace the function - called to actually save the page by ``page_save``. It patches the - bot class as soon as this class' attribute bot is defined. It also - sets the bot's 'always' option to True to avoid user interaction. - - The ``bot_save`` method compares the save counter before the call and - asserts that it has increased by one after the call. It also stores - locally in ``save_called`` if ``page_save`` has been called. If - ``bot_save`` or ``page_save`` are implemented they should call - super's method at some point to make sure these assertions work. At - ``tearDown`` it checks that the pages are saved often enough. The - attribute ``default_assert_saves`` defines the number of saves which - must happen and compares it to the difference using the save counter. - It is possible to define ``assert_saves`` after ``setUp`` to - overwrite the default value for certain tests. By default the number - of saves it asserts are 1. Additionally ``save_called`` increases by - 1 on each call of ``page_save`` and should be equal to - ``assert_saves``. - - This means if the bot class actually does other writes, like using - :py:obj:`pywikibot.page.Page.save` manually, it'll still write. - """ - - @property - def bot(self): - """Get the current bot.""" - return self._bot - - @bot.setter - def bot(self, value): - """Set and patch the current bot.""" - assert value._save_page != self.bot_save, 'bot may not be patched.' - self._bot = value - self._bot.opt.always = True - self._original = self._bot._save_page - self._bot._save_page = self.bot_save - self._old_counter = self._bot.counter['write'] - - def setUp(self): - """Set up test by resetting the counters.""" - super().setUp() - self.assert_saves = getattr(self, 'default_assert_saves', 1) - self.save_called = 0 - - def tearDown(self): - """Tear down by asserting the counters.""" - self.assertEqual(self._bot.counter['write'], - self._old_counter + self.assert_saves) - self.assertEqual(self.save_called, self.assert_saves) - super().tearDown() - - def bot_save(self, page, func, *args, **kwargs): - """Handle when bot's userPut was called.""" - self.assertGreaterEqual(self._bot.counter['write'], 0) - old_counter = self._bot.counter['write'] - old_local_cnt = self.save_called - result = self._original(page, self.page_save, *args, **kwargs) - self.assertEqual(self._bot.counter['write'], old_counter + 1) - self.assertEqual(self.save_called, old_local_cnt + 1) - self.assertGreater(self._bot.counter['write'], self._old_counter) - return result - - def page_save(self, *args, **kwargs): - """Handle when bot calls the page's save method.""" - self.save_called += 1 - - class TestBotTreatExit:
"""Mixin to provide handling for treat and exit.""" diff --git a/tests/i18n/pywikibot.py b/tests/i18n/pywikibot.py deleted file mode 100644 index 8fc88bf..0000000 --- a/tests/i18n/pywikibot.py +++ /dev/null @@ -1,7 +0,0 @@ -"""i18n message bundle called 'pywikibot' to fool the i18n loader.""" -# -# (C) Pywikibot team, 2014-2020 -# -# Distributed under the terms of the MIT license. -# -msg = {}
pywikibot-commits@lists.wikimedia.org