-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Description
Here's the code snippet:
import json
import aiohttp
import asyncio
import async_timeout
from unittest import TestCase
import unittest
from mocket.plugins.httpretty import HTTPretty, httprettified
class AioHttpEntryTestCase(TestCase):
@httprettified
def test_https_session(self):
url = 'https://httpbin.org/ip'
HTTPretty.register_uri(
HTTPretty.GET,
url,
body=json.dumps(dict(origin='127.0.0.1')),
)
async def main(l):
async with aiohttp.ClientSession(loop=l) as session:
with async_timeout.timeout(3):
async with session.get(url) as get_response:
assert get_response.status == 200
assert await get_response.text() == '{"origin": "127.0.0.1"}'
loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(main(loop))
if __name__ == '__main__':
unittest.main()Exception:
E/usr/lib/python3.6/unittest/case.py:633: ResourceWarning: unclosed <socket object, fd=5, family=1, type=1, proto=0>
outcome.errors.clear()
/usr/lib/python3.6/asyncio/base_events.py:516: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
source=self)
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=False debug=False>>
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/base_events.py", line 518, in __del__
self.close()
File "/usr/lib/python3.6/asyncio/unix_events.py", line 63, in close
super().close()
File "/usr/lib/python3.6/asyncio/selector_events.py", line 110, in close
self._close_self_pipe()
File "/usr/lib/python3.6/asyncio/selector_events.py", line 120, in _close_self_pipe
self._remove_reader(self._ssock.fileno())
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_ssock'
======================================================================
ERROR: test_https_session (__main__.AioHttpEntryTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "</home/dvnguyen/code/pyvenvs/redesign36/lib/python3.6/site-packages/decorator.py:decorator-gen-1>", line 2, in test_https_session
File "/home/dvnguyen/code/pyvenvs/redesign36/lib/python3.6/site-packages/mocket/mocket.py", line 572, in wrapper
t(*args, **kw)
File "moctests.py", line 29, in test_https_session
loop = asyncio.get_event_loop()
File "/usr/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
return get_event_loop_policy().get_event_loop()
File "/usr/lib/python3.6/asyncio/events.py", line 599, in get_event_loop
self.set_event_loop(self.new_event_loop())
File "/usr/lib/python3.6/asyncio/events.py", line 617, in new_event_loop
return self._loop_factory()
File "/usr/lib/python3.6/asyncio/unix_events.py", line 56, in __init__
super().__init__(selector)
File "/usr/lib/python3.6/asyncio/selector_events.py", line 67, in __init__
self._make_self_pipe()
File "/usr/lib/python3.6/asyncio/selector_events.py", line 129, in _make_self_pipe
self._ssock, self._csock = self._socketpair()
File "/usr/lib/python3.6/asyncio/unix_events.py", line 60, in _socketpair
return socket.socketpair()
File "/usr/lib/python3.6/socket.py", line 490, in socketpair
a = socket(family, type, proto, a.detach())
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (errors=1)
OS: Ubuntu 18.10
Python version: 3.5.6, 3.6.7, 3.7.1
mocket version: 2.7.1
Metadata
Metadata
Assignees
Labels
No labels