jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761342 )
Change subject: [cleanup] remove deprecated http.get_fake_user_agent() function ......................................................................
[cleanup] remove deprecated http.get_fake_user_agent() function
- http.get_fake_user_agent() function is nowhere used in the framework and deprecated for over 5 years. - also config.fake_user_agent isn't used anywhere in the famework an is deprecated for years; it can be removed. - remove GetFakeUserAgentTestCase
Change-Id: I30f5ffffd0a5c81c06ce68608bfb412f12238a09 --- M pywikibot/comms/http.py M pywikibot/config.py M tests/http_tests.py 3 files changed, 2 insertions(+), 60 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 6a99a24..ad635a0 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -22,7 +22,7 @@ :py:obj:`flush()` can be called to close the session object. """ # -# (C) Pywikibot team, 2007-2021 +# (C) Pywikibot team, 2007-2022 # # Distributed under the terms of the MIT license. # @@ -48,10 +48,7 @@ Server504Error, ) from pywikibot.logging import critical, debug, error, log, warning -from pywikibot.tools import ( - deprecated, - file_mode_checker, -) +from pywikibot.tools import file_mode_checker
try: @@ -194,22 +191,6 @@ return formatted
-@deprecated('pywikibot.comms.http.fake_user_agent', since='20161205') -def get_fake_user_agent(): - """ - Return a fake user agent depending on `fake_user_agent` option in config. - - Deprecated, use fake_user_agent() instead. - - :rtype: str - """ - if isinstance(config.fake_user_agent, str): - return config.fake_user_agent - if config.fake_user_agent is False: - return user_agent() - return fake_user_agent() - - def fake_user_agent() -> str: """Return a fake user agent.""" try: diff --git a/pywikibot/config.py b/pywikibot/config.py index 09c185f..a60dad2 100644 --- a/pywikibot/config.py +++ b/pywikibot/config.py @@ -159,8 +159,6 @@ # Example: {'problematic.site.example': True, # 'prefers.specific.ua.example': 'snakeoil/4.2'} fake_user_agent_exceptions = {} # type: Dict[str, Union[bool, str]] -# This following option is deprecated in favour of finer control options above. -fake_user_agent = False
# The default interface for communicating with the site # currently the only defined interface is 'APISite', so don't change this! diff --git a/tests/http_tests.py b/tests/http_tests.py index 62b066e..d52dd1a 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -303,43 +303,6 @@ self._test_fetch_use_fake_user_agent()
-class GetFakeUserAgentTestCase(TestCase): - - """Test the deprecated get_fake_user_agent().""" - - net = False - - def setUp(self): - """Set up unit test.""" - self.orig_fake_user_agent = config.fake_user_agent - super().setUp() - - def tearDown(self): - """Tear down unit test.""" - config.fake_user_agent = self.orig_fake_user_agent - super().tearDown() - - def _test_config_settings(self): - """Test if method honours configuration toggle.""" - with suppress_warnings(r'.*?get_fake_user_agent is deprecated'): - # ON: True and None in config are considered turned on. - config.fake_user_agent = True - self.assertNotEqual(http.get_fake_user_agent(), http.user_agent()) - config.fake_user_agent = None - self.assertNotEqual(http.get_fake_user_agent(), http.user_agent()) - - # OFF: All other values won't make it return random UA. - config.fake_user_agent = False - self.assertEqual(http.get_fake_user_agent(), http.user_agent()) - config.fake_user_agent = 'ARBITRARY' - self.assertEqual(http.get_fake_user_agent(), 'ARBITRARY') - - @require_modules('fake_useragent') - def test_with_fake_useragent(self): - """Test method with fake_useragent module.""" - self._test_config_settings() - - class CharsetTestCase(TestCase):
"""Test that HttpRequest correct handles the charsets given."""
pywikibot-commits@lists.wikimedia.org