Repository: aio-libs/aiohttp

Issue:
Move DummyCookieJar into cookiejar.py
And mention it in client documentation.


Discussion:

Resolving patch:
diff --git a/aiohttp/__init__.py b/aiohttp/__init__.py
--- a/aiohttp/__init__.py
+++ b/aiohttp/__init__.py
@@ -10,7 +10,7 @@
                    WSMsgType, WSCloseCode, WSMessage, WebSocketError)  # noqa
 from .streams import *  # noqa
 from .multipart import *  # noqa
-from .cookiejar import CookieJar  # noqa
+from .cookiejar import *  # noqa
 from .payload import *  # noqa
 from .payload_streamer import *  # noqa
 from .resolver import *  # noqa
@@ -23,6 +23,7 @@
 
 
 __all__ = (client.__all__ +  # noqa
+           cookiejar.__all__ +  # noqa
            formdata.__all__ +  # noqa
            helpers.__all__ +  # noqa
            multipart.__all__ +  # noqa
@@ -31,5 +32,5 @@
            streams.__all__ +  # noqa
            ('hdrs', 'HttpVersion', 'HttpVersion10', 'HttpVersion11',
             'WSMsgType', 'WSCloseCode',
-            'WebSocketError', 'WSMessage', 'CookieJar',
+            'WebSocketError', 'WSMessage',
            ) + workers)
diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py
--- a/aiohttp/cookiejar.py
+++ b/aiohttp/cookiejar.py
@@ -13,6 +13,9 @@
 from .helpers import SimpleCookie, is_ip_address
 
 
+__all__ = ('CookieJar', 'DummyCookieJar')
+
+
 class CookieJar(AbstractCookieJar):
     """Implements cookie storage adhering to RFC 6265."""
 
@@ -304,3 +307,30 @@ def _parse_date(cls, date_str):
         return datetime.datetime(year, month, day,
                                  hour, minute, second,
                                  tzinfo=datetime.timezone.utc)
+
+
+class DummyCookieJar(AbstractCookieJar):
+    """Implements a dummy cookie storage.
+
+    It can be used with the ClientSession when no cookie processing is needed.
+
+    """
+
+    def __init__(self, *, loop=None):
+        super().__init__(loop=loop)
+
+    def __iter__(self):
+        while False:
+            yield None
+
+    def __len__(self):
+        return 0
+
+    def clear(self):
+        pass
+
+    def update_cookies(self, cookies, response_url=None):
+        pass
+
+    def filter_cookies(self, request_url):
+        return None
diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py
--- a/aiohttp/helpers.py
+++ b/aiohttp/helpers.py
@@ -21,7 +21,6 @@
 from async_timeout import timeout
 
 from . import hdrs
-from .abc import AbstractCookieJar
 
 
 try:
@@ -40,7 +39,7 @@
 
 
 __all__ = ('BasicAuth', 'create_future', 'parse_mimetype',
-           'Timeout', 'ensure_future', 'noop', 'DummyCookieJar')
+           'Timeout', 'ensure_future', 'noop')
 
 
 sentinel = object()
@@ -794,30 +793,3 @@ def content_length(self, *, _CONTENT_LENGTH=hdrs.CONTENT_LENGTH):
             return None
         else:
             return int(l)
-
-
-class DummyCookieJar(AbstractCookieJar):
-    """Implements a dummy cookie storage.
-
-    It can be used with the ClientSession when no cookie processing is needed.
-
-    """
-
-    def __init__(self, *, loop=None):
-        super().__init__(loop=loop)
-
-    def __iter__(self):
-        while False:
-            yield None
-
-    def __len__(self):
-        return 0
-
-    def clear(self):
-        pass
-
-    def update_cookies(self, cookies, response_url=None):
-        pass
-
-    def filter_cookies(self, request_url):
-        return None


Test patch:
diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py
--- a/tests/test_cookiejar.py
+++ b/tests/test_cookiejar.py
@@ -9,7 +9,7 @@
 import pytest
 from yarl import URL
 
-from aiohttp import CookieJar
+from aiohttp import CookieJar, DummyCookieJar
 from aiohttp.helpers import SimpleCookie
 
 
@@ -596,3 +596,15 @@ def test_cookie_not_expired_when_added_after_removal(self):
 
         # Assert that there is a cookie.
         assert len(jar) == 1
+
+
+def test_dummy_cookie_jar(loop):
+    cookie = SimpleCookie('foo=bar; Domain=example.com;')
+    dummy_jar = DummyCookieJar(loop=loop)
+    assert len(dummy_jar) == 0
+    dummy_jar.update_cookies(cookie)
+    assert len(dummy_jar) == 0
+    with pytest.raises(StopIteration):
+        next(iter(dummy_jar))
+    assert dummy_jar.filter_cookies(URL("http://example.com/")) is None
+    dummy_jar.clear()
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -6,7 +6,6 @@
 from unittest import mock
 
 import pytest
-from yarl import URL
 
 from aiohttp import helpers
 
@@ -547,15 +546,3 @@ def test_set_content_disposition_bad_param():
     with pytest.raises(ValueError):
         helpers.content_disposition_header('inline',
                                            **{'foo\x00bar': 'baz'})
-
-
-def test_dummy_cookie_jar(loop):
-    cookie = helpers.SimpleCookie('foo=bar; Domain=example.com;')
-    dummy_jar = helpers.DummyCookieJar(loop=loop)
-    assert len(dummy_jar) == 0
-    dummy_jar.update_cookies(cookie)
-    assert len(dummy_jar) == 0
-    with pytest.raises(StopIteration):
-        next(iter(dummy_jar))
-    assert dummy_jar.filter_cookies(URL("http://example.com/")) is None
-    dummy_jar.clear()