https://prefect.io logo
f

Farhood Etaati

07/25/2023, 3:09 PM
How do I change the log level to debug in my tests? I'm trying to use a fixture like this:
Copy code
@pytest.fixture(autouse=True, scope="session")
def _prefect_debug_log_level() -> Generator[None, Any, None]:
    with temporary_settings(updates={PREFECT_LOGGING_LEVEL: "DEBUG"}):
        yield
But my test does not show the debug logs:
Copy code
@flow
def my_flow():
   get_run_logger().debug("Hi this is a sample flow!")

@pytest.mark.unit_test()
@pytest.mark.asyncio()
async def test_flow(
    _prefect_debug_log_level: None,
) -> None:
   with prefect_test_harness(): 
       my_flow() # Does not show the debug log in the flow