def METHOD_NAME(app: Sanic):
    def foo(*_):
        ...
    app.register_middleware(foo, priority=999)
    assert len(app.request_middleware) == 1
    assert len(app.response_middleware) == 0
    assert app.request_middleware[0].priority == 999  # type: ignore
    app.register_middleware(foo, attach_to="response", priority=999)
    assert len(app.request_middleware) == 1
    assert len(app.response_middleware) == 1
    assert app.response_middleware[0].priority == 999  # type: ignore