betty.assertion.error module¶
Provide assertion failures.
- class betty.assertion.error.AssertionContext[source]¶
Bases:
ABCThe context in which an assertion is invoked.
- exception betty.assertion.error.AssertionFailed[source]¶
Bases:
UserFacingError,ValueErrorAn assertion failure.
- __init__(message: Localizable, *, contexts: tuple[AssertionContext | Localizable, ...] | None = None)[source]¶
- property contexts: tuple[AssertionContext | Localizable, ...]¶
Get the human-readable contexts describing where the error occurred in the source data.
- localize(localizer: Localizer) LocalizedStr[source]¶
Localize
selfto a human-readable string.
- raised(error_type: type[AssertionFailed]) bool[source]¶
Check if the error matches the given error type.
- with_context(*contexts: AssertionContext | Localizable) Self[source]¶
Add a message describing the error’s context.
- exception betty.assertion.error.AssertionFailedGroup[source]¶
Bases:
AssertionFailedA group of zero or more assertion failures.
- __init__(errors: Sequence[AssertionFailed] | None = None)[source]¶
- append(*errors: AssertionFailed) None[source]¶
Append errors to this collection.
- assert_valid(*contexts: AssertionContext | Localizable) Iterator[Self][source]¶
Assert that this collection contains no errors.
- catch(*contexts: AssertionContext | Localizable) Iterator[AssertionFailedGroup][source]¶
Catch any errors raised within this context manager and add them to the collection.
- Returns:
A new collection that will only contain any newly raised errors.
- localize(localizer: Localizer) LocalizedStr[source]¶
Localize
selfto a human-readable string.
- raised(error_type: type[AssertionFailed]) bool[source]¶
Check if the error matches the given error type.
- with_context(*contexts: AssertionContext | Localizable) Self[source]¶
Add a message describing the error’s context.
- class betty.assertion.error.Attr[source]¶
Bases:
AssertionContextAn object attribute context.
- class betty.assertion.error.Index[source]¶
Bases:
AssertionContextA sequence index context.
- class betty.assertion.error.Key[source]¶
Bases:
AssertionContextA mapping key context.
- betty.assertion.error.localizable_contexts(*contexts: Contextey) Sequence[Localizable][source]¶
The contexts as
betty.locale.localizable.Localizableinstances.