Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientSession is not aware of TestClient #1499

Closed
saaj opened this issue Dec 23, 2016 · 3 comments
Closed

ClientSession is not aware of TestClient #1499

saaj opened this issue Dec 23, 2016 · 3 comments
Labels

Comments

@saaj
Copy link

saaj commented Dec 23, 2016

There's a ResourceWarning and message per test method in test_utils.AioHTTPTestCase. The following produces:

from aiohttp import web, test_utils

class TestCase(test_utils.AioHTTPTestCase):

    def get_app(self, loop):
        return web.Application(loop = loop)

    def test1(self):
        pass

    def test2(self):
        pass

python -m unittest test

aiohttp/test_utils.py:212: ResourceWarning: Creating a client session outside of coroutine is a very dangerous idea
  **kwargs)
Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7f5cbc921cc0>
.Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7f5cbc921e48>

This is because ClientSession expects running IO loop.

Note that there's not only a warning, but also a call to loop.call_exception_handler() with mocked context, so this is impossible prevent this output with normal Python warnings.filterwarnings which is likely an warning design issue in the package.

aiohttp 1.2.0

@AraHaan
Copy link
Contributor

AraHaan commented Dec 24, 2016

I am considering adding an optional arg to ClientSession that if set to False then no warning messages would be displayed. (at least upon Creation and Deletion) but only if set to False that is.

@asvetlov
Copy link
Member

Fixed. get_application() now is recommended way for application creation but get_app() is still supported.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants