Warning: Bocadillo is now UNMAINTAINED. Users are recommended to migrate to a supported alternative, such as Starlette or FastAPI. Please see #344 for more information.



create_client(app:'App', **kwargs) -> starlette.testclient.TestClient

Create a Starlette Test Client out of an application.


  • app: an #::bocadillo.applications#App instance.
  • **kwargs (any): keyword arguments passed to the TestClient constructor.


client (TestClient): a Starlette test client.


LiveServer(self, app:'App', ready_timeout:float=5, stop_timeout:float=5, **kwargs)

Context manager to spin up a live uvicorn server in a separate process.

The server process is terminated when exiting the context.


  • app: an #::bocadillo.applications#App instance.
  • ready_timeout (float): The maximum time to wait for the live server to be ready to handle connections, in seconds. Defaults to 5.
  • stop_timeout (float): The maximum time to wait for the live server to terminate, in seconds. Defaults to 5.
  • **kwargs (any): keyword arguments passed to uvicorn.run(). host defaults to "" (i.e. localhost). port defaults to a random integer between 3000 and 9999.


  • url (str): the full URL where the server lives. Build a full URL by calling this attribute, e.g. server.url("/path/foo").