-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changing state of started or joined application is deprecated....grrrr #1947
Comments
Hmm. As I see in code for |
import pytest
from aiohttp import web
async def startup(app):
app['foobar'] = 123
async def handle(request):
return web.Response(text='hello')
def create_app():
app = web.Application()
app.on_startup.append(startup)
app.router.add_get('/', handle)
return app
@pytest.fixture
def cli(loop, test_client):
app = create_app()
return loop.run_until_complete(test_client(app))
async def test_hello(cli):
resp = await cli.get('/')
assert resp.status == 200
text = await resp.text()
assert 'o' in text Then run
gives: |
The error was in |
Ooop, something is wrong with |
Finally fixed |
Long story short
I very often want to set items on "frozen" app. I'm getting depreciation warnings for this and in future (presumably) this will fail outright. This is very frustrating.
This is made worse by pytest 3.1 which prints all warnings making this harder to ignore.
Expected behaviour
In a startup function should not cause deprecation warnings.
Actual behaviour
I'm getting warnings in lots of setups which I would have thought sensible.
Examples
in unit tests setting up a secondary server:
This causes a warning because I'm setting the
server_name
item on an app which is started.using startup function:
(real life example here)
This again causes warnings setting
pg_engine
in a startup script.Workaround
Surely this warning is wrong? If not what workaround should I use?
The only solution I can think of is an ugly bodge:
The text was updated successfully, but these errors were encountered: