From 88f7ed8a6318fe211bdc4787c5826283c4dc301c Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Sep 2016 20:18:30 +0300 Subject: [PATCH] Fix #1203: Create CookieJar without explicit loop passing --- CHANGES.rst | 2 +- aiohttp/cookiejar.py | 2 +- tests/test_cookiejar.py | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9afe3af0f9a..8dce3e768da 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ CHANGES - Add missing `WSMsgType` to `web_ws.__all__`, see #1200 -- +- Fix `CookieJar` ctor when called with `loop=None` #1203 - diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py index 6e11ad525d8..907b0ca52fc 100644 --- a/aiohttp/cookiejar.py +++ b/aiohttp/cookiejar.py @@ -33,7 +33,7 @@ def __init__(self, *, unsafe=False, loop=None): self._cookies = defaultdict(SimpleCookie) self._host_only_cookies = set() self._unsafe = unsafe - self._next_expiration = ceil(loop.time()) + self._next_expiration = ceil(self._loop.time()) self._expirations = {} def clear(self): diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py index 37ab3fcc044..359fb63d2f7 100644 --- a/tests/test_cookiejar.py +++ b/tests/test_cookiejar.py @@ -140,6 +140,12 @@ def test_constructor(loop, cookies_to_send, cookies_to_receive): assert jar._loop is loop +def test_ctor_ith_default_loop(loop): + asyncio.set_event_loop(loop) + jar = CookieJar() + assert jar._loop is loop + + def test_domain_filter_ip_cookie_send(loop): jar = CookieJar(loop=loop) cookies = SimpleCookie(