def persist_db(tmpdir):
    """ensure db will persist (overrides default sqlite://:memory:)"""
    if os.getenv('JUPYTERHUB_TEST_DB_URL'):
        # already using a db, no need
        yield
        return
    with patch.dict(
        os.environ,
        {'JUPYTERHUB_TEST_DB_URL': f"sqlite:///{tmpdir.join('jupyterhub.sqlite')}"},
    ):
        yield
ensure db will persist (overrides default sqlite://:memory:)
jupyterhub/tests/test_app.py