def METHOD_NAME(request, _app: Devicehub) -> Devicehub:
    # More robust than 'yield'
    def _drop(*args, **kwargs):
        with _app.app_context():
            db.drop_all()
    def _init():
        _app.init_db(
            name='Test Inventory',
            org_name='FooOrg',
            org_id='foo-org-id',
            tag_url=boltons.urlutils.URL('https://example.com'),
            tag_token=uuid.UUID('52dacef0-6bcb-4919-bfed-f10d2c96ecee'),
            erase=False,
            common=True,
        )
    with _app.app_context():
        try:
            with redirect_stdout(io.StringIO()):
                _init()
        except (ProgrammingError, IntegrityError, AssertionError):
            print('Database was not correctly emptied. Re-empty and re-installing...')
            _drop()
            _init()
    request.addfinalizer(_drop)
    return _app