Skip to content

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

@xiaoxiper

Description

@xiaoxiper

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions