Hello! I was curious to understand how the get_run_logger
abstraction works when trying to unit test tasks. I’m trying to test a task using the instructions here, but I keep getting the following error when running my unit test:
E RuntimeError: There is no active flow or task run context.
What would be the best way to work around this issue for unit testing tasks? I can see certain tests from the prefect-aws
repo that one potential workaround is to create a temporary flow just for testing and running the flow instead of running the individual tasks.
Minimal reproducible example:
from prefect import task, get_run_logger
@task
def example_task():
logger = get_run_logger()
logger.info("This will break the test")
return 42
def test_example_task():
assert example_task.fn() == 42