Errors¶
Every error Hegel raises about a run, rather than one raised by the test
itself, is a HegelError. The exception is MultipleFailures,
which groups the test’s own exceptions when a run reports more than one
failure.
- exception hegel.InvalidArgument¶
Bases:
HegelErrorAn argument passed to Hegel was invalid.
- exception hegel.RunError¶
Bases:
HegelErrorThe engine aborted the run rather than reporting a pass or a test failure: a failed health check (
FailedHealthCheck), nondeterminism under theerrorstrictness (Flaky), too few valid test cases (Unsatisfiable), or another engine error. The message explains which.
- exception hegel.FailedHealthCheck(message: str, health_check: HealthCheck | None = None)¶
Bases:
RunErrorA health check failed: the run was likely to test poorly or slowly (too many rejected test cases, say).
health_checkis theHealthCheckthat failed, and the message names it and says how to suppress it withsuppress_health_checkif the behaviour is intentional.
- exception hegel.Unsatisfiable¶
Bases:
RunErrorThe engine could not find enough inputs satisfying the test’s assumptions and filters. With the
filter_too_muchhealth check enabled, a run that rejects nearly everything fails that check (FailedHealthCheck) first.
- exception hegel.Flaky¶
Bases:
RunErrorThe engine aborted the run because the test behaved nondeterministically, under
NondeterminismStrictness.error. The default strictness instead confirms such failures by repeated replay and reports them with a caveat.
- exception hegel.DidNotReproduce¶
Bases:
HegelErrorThe blob given to
reproduce_failure()no longer makes the test fail: the bug is fixed (remove the decorator) or the test has changed so the blob means something else.
- exception hegel.ResolutionFailed¶
Bases:
InvalidArgumentfrom_type()could not find a generator for a type. Raised when the generator is built; a subclass ofInvalidArgument.
- exception hegel.NotPrintable¶
Bases:
InvalidArgumentTestCase.drawwas given a generator that cannot print the values it draws: aGeneratorsubclass that implements onlydo_draw, or a structure containing one. Raised from the draw, on the first test case that reaches it; a subclass ofInvalidArgument, so it ends the run as a usage error. Implementdo_draw_and_printon the generator, make it printable withprint_with()orprint_as_repr(), or draw it withTestCase.draw_silent.
- exception hegel.BackendError¶
Bases:
HegelErrorThe Hegel engine reported an error.
- exception hegel.InternalError¶
Bases:
HegelErrorAn internal error in Hegel. Please report this as a bug.
- exception hegel.MultipleFailures(message: str, exceptions: Any)¶
Bases:
BaseExceptionGroupA run found several distinct failures, with
report_multiple_failures=True. Each failure is inexceptions, with its own falsifying example attached as notes.Like the built-in exception groups, an instance whose failures are all
Exceptions is itself anExceptionGroup, soexcept Exceptioncatches it; one with aBaseExceptionamong them is only aBaseExceptionGroup.
Control flow¶
These exceptions are how Hegel ends a test case early. A test should let them propagate.
- exception hegel.AssumeFailed¶
Bases:
BaseExceptionControl flow: the current test case was rejected by an assumption.
- exception hegel.StopTest¶
Bases:
BaseExceptionControl flow: the engine abandoned the current test case.