jenkins-bot has submitted this change and it was merged.
Change subject: Deprecate pywikibot.cookie_jar ......................................................................
Deprecate pywikibot.cookie_jar
It should be accessed via the http module.
Change-Id: I4026eacea61a5b81524216ea0cabe25b1d80c1cc --- M pywikibot/__init__.py M pywikibot/comms/http.py M pywikibot/data/api.py M tests/http_tests.py 4 files changed, 21 insertions(+), 7 deletions(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 62a920c..290a925 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -751,6 +751,8 @@ wrapper = pywikibot.tools.ModuleDeprecationWrapper(__name__) wrapper._add_deprecated_attr('ImagePage', FilePage) wrapper._add_deprecated_attr( + 'cookie_jar', replacement_name='pywikibot.comms.http.cookie_jar') +wrapper._add_deprecated_attr( 'PageNotFound', pywikibot.exceptions.DeprecatedPageNotFoundError, warning_message=('{0}.{1} is deprecated, and no longer ' 'used by pywikibot; use http.fetch() instead.')) diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 5bccc54..7a54e07 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -91,11 +91,6 @@ pywikibot.log('Network session closed.') atexit.register(_flush)
- -# export cookie_jar to global namespace -pywikibot.cookie_jar = cookie_jar - - USER_AGENT_PRODUCTS = { 'python': 'Python/' + '.'.join([str(i) for i in sys.version_info]), 'http_backend': 'requests/' + requests.__version__, diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index b63c835..e5f6873 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -3016,7 +3016,7 @@
def storecookiedata(self, data): """Ignore data; cookies are set by threadedhttp module.""" - pywikibot.cookie_jar.save() + http.cookie_jar.save()
def update_page(page, pagedict, props=[]): diff --git a/tests/http_tests.py b/tests/http_tests.py index 41c3c29..b912376 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Tests for http module.""" # -# (C) Pywikibot team, 2014 +# (C) Pywikibot team, 2014-2015 # # Distributed under the terms of the MIT license. # @@ -391,6 +391,23 @@ self.assertEqual(r.raw, self.png)
+class TestDeprecatedGlobalCookieJar(DeprecationTestCase): + + """Test usage of deprecated pywikibot.cookie_jar.""" + + net = False + + def test_cookie_jar(self): + """Test pywikibot.cookie_jar is deprecated.""" + # Accessing from the main package should be deprecated. + main_module_cookie_jar = pywikibot.cookie_jar + + self.assertOneDeprecationParts('pywikibot.cookie_jar', + 'pywikibot.comms.http.cookie_jar') + + self.assertIs(main_module_cookie_jar, http.cookie_jar) + + if __name__ == '__main__': try: unittest.main()