

@pytest.yield_fixture
def query_recorder(app_config):
    recorder = QueryRecorder()
    engine = app_config.registry['sqlalchemy.engine']
    event.listen(engine, 'before_cursor_execute', recorder.record)
    try:
        (yield recorder)
    finally:
        event.remove(engine, 'before_cursor_execute', recorder.record)

dataset/ETHPy150Open pypa/warehouse/tests/conftest.py query_recorder/original