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

Upgrade to pytest-sanic 1.7.1 and sanic 21.3.4 failed with "sanic_routing.exceptions.FinalizationError: Cannot finalize router more than once." #53

Open
xiaoxiper opened this issue May 23, 2021 · 3 comments

Comments

@xiaoxiper
Copy link

Hi!
I use Blueprint groups, it was ok when I used sanic 20.x with pytest-sanic 1.7.0.
But when I upgraded, I encountered the following:

    @pytest.fixture
    def test_cli(loop, app, sanic_client):
>       return loop.run_until_complete(sanic_client(app))

tests/api/base.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
uvloop/loop.pyx:1456: in uvloop.loop.Loop.run_until_complete
    ???
.venv/lib/python3.8/site-packages/pytest_sanic/plugin.py:203: in create_client
    await client.start_server()
.venv/lib/python3.8/site-packages/pytest_sanic/utils.py:227: in start_server
    await self._server.start_server()
.venv/lib/python3.8/site-packages/pytest_sanic/utils.py:104: in start_server
    await trigger_events(self.before_server_start, self.loop)
.venv/lib/python3.8/site-packages/pytest_sanic/utils.py:30: in trigger_events
    await result
.venv/lib/python3.8/site-packages/sanic/app.py:1285: in finalize
    raise e  # noqa
.venv/lib/python3.8/site-packages/sanic/app.py:1280: in finalize
    app.router.finalize()
.venv/lib/python3.8/site-packages/sanic/router.py:179: in finalize
    super().finalize(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sanic.router.Router object at 0x112b83b20>, do_compile = True

    def finalize(self, do_compile: bool = True):
        if self.finalized:
>           raise FinalizationError("Cannot finalize router more than once.")
E           sanic_routing.exceptions.FinalizationError: Cannot finalize router more than once.
@mvbrn
Copy link

mvbrn commented Jun 9, 2021

i have the same thing, any workarounds?

@michel-rodrigues
Copy link

I have the same problem

@yunstanford
Copy link
Owner

yunstanford commented Jul 27, 2021

any sample code for me to reproduce ?

Tried with one simple test (e76ddeb), seems working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants