betty.assertion.error module¶
Provide assertion failures.
- exception betty.assertion.error.AssertionFailed[source]¶
Bases:
UserFacingError
,ValueError
An assertion failure.
- __init__(message: Localizable)[source]¶
- property contexts: tuple[Localizable, ...]¶
Get the human-readable contexts describing where the error occurred in the source data.
- localize(localizer: Localizer) LocalizedStr [source]¶
Localize
self
to a human-readable string.
- raised(error_type: type[AssertionFailed]) bool [source]¶
Check if the error matches the given error type.
- with_context(*contexts: Localizable) Self [source]¶
Add a message describing the error’s context.
- exception betty.assertion.error.AssertionFailedGroup[source]¶
Bases:
AssertionFailed
A group of zero or more assertion failures.
- __init__(errors: Sequence[AssertionFailed] | None = None)[source]¶
- append(*errors: AssertionFailed) None [source]¶
Append errors to this collection.
- catch(*contexts: 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
self
to a human-readable string.
- raised(error_type: type[AssertionFailed]) bool [source]¶
Check if the error matches the given error type.
- with_context(*contexts: Localizable) Self [source]¶
Add a message describing the error’s context.