jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1304749?usp=email )
Change subject: tests: simplify DefaultUserAgentTestCase
......................................................................
tests: simplify DefaultUserAgentTestCase
remove setUp/tearDown and use the original config ua for tests
but ignore username in front of the UA string. This avoids
deprecation warnings within this test.
Change-Id: If1ae6484b01fc0976de0def3a1078896769c262b
---
M tests/http_tests.py
1 file changed, 10 insertions(+), 21 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 1524dee..f018cce 100755
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -227,29 +227,18 @@
net = False
- def setUp(self) -> None:
- """Set up unit test."""
- super().setUp()
- self.orig_format = config.user_agent_format
- config.user_agent_format = ('{script_product} ({script_comments}) '
- '{pwb} ({revision}) {http_backend} '
- '{python}')
-
- def tearDown(self) -> None:
- """Tear down unit test."""
- super().tearDown()
- config.user_agent_format = self.orig_format
-
def test_default_user_agent(self) -> None:
"""Config defined format string test."""
- self.assertStartsWith(http.user_agent(), pywikibot.calledModuleName())
- self.assertIn('Pywikibot/' + pywikibot.__version__, http.user_agent())
- self.assertNotIn(' ', http.user_agent())
- self.assertNotIn('()', http.user_agent())
- self.assertNotIn('(;', http.user_agent())
- self.assertNotIn(';)', http.user_agent())
- self.assertIn('requests/', http.user_agent())
- self.assertIn('Python/' + str(PYTHON_VERSION[0]), http.user_agent())
+ ua = http.user_agent()
+ ua = ua.split('/', 1)[1] # remove username part
+ self.assertStartsWith(ua, pywikibot.calledModuleName())
+ self.assertIn('Pywikibot/' + pywikibot.__version__, ua)
+ self.assertNotIn(' ', ua)
+ self.assertNotIn('()', ua)
+ self.assertNotIn('(;', ua)
+ self.assertNotIn(';)', ua)
+ self.assertIn('requests/', ua)
+ self.assertIn('Python/' + str(PYTHON_VERSION[0]), ua)
@require_modules('fake_useragent')
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1304749?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If1ae6484b01fc0976de0def3a1078896769c262b
Gerrit-Change-Number: 1304749
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]