jenkins-bot submitted this change.

View Change

Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
[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(-)

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."""

To view, visit change 761342. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I30f5ffffd0a5c81c06ce68608bfb412f12238a09
Gerrit-Change-Number: 761342
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: MtDu <justin.d128@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged