Unit testing best practices for Prefect flows, subflows and tasks

The answer I got so far:

  • You can disable the Python logger e.g. logging.getLogger("prefect").enabled = False or PREFECT_LOGGING_LEVEL=ERROR
  • If you want the logger temporarily disabled for some tests, you can write a fixture that sets and unsets the enabled attribute. It must be set after prefect.logging.setup_logging is called.
1 Like