prefect.testing
utilities
prefect.testing.utilities
Internal utilities for tests.
Functions
exceptions_equal
Exceptions cannot be compared by ==
. They can be compared using is
but this
will fail if the exception is serialized/deserialized so this utility does its
best to assert equality using the type and args used to initialize the exception
kubernetes_environments_equal
assert_does_not_warn
Converts warnings to errors within this context to assert warnings are not raised, except for those specified in ignore_warnings.
Parameters:
- ignore_warnings: List of warning types to ignore. Example: [DeprecationWarning, UserWarning]
prefect_test_harness
Temporarily run flows against a local SQLite database for testing.
Args:
server_startup_timeout
: The maximum time to wait for the server to start. Defaults to 30 seconds. If set toNone
, the value ofPREFECT_SERVER_EPHEMERAL_STARTUP_TIMEOUT_SECONDS
will be used.
Examples:
from prefect import flow from prefect.testing.utilities import prefect_test_harness
@flow def my_flow(): return ‘Done!’
with prefect_test_harness(): assert my_flow() == ‘Done!’ # run against temporary db