valid8r.testing.assertions
Assertion helpers for testing with Maybe monads.
Attributes
Functions
|
Assert that a Maybe is a Success with the expected value. |
|
Assert that a Maybe is a Failure with the expected error message. |
|
Assert error via error_or helper. |
Module Contents
- valid8r.testing.assertions.assert_maybe_success(result, expected_value)[source]
Assert that a Maybe is a Success with the expected value.
- Parameters:
result (valid8r.core.maybe.Maybe[T]) – The Maybe instance to check
expected_value (Any) – The expected value inside the Maybe
- Returns:
True if result is a Success with the expected value, False otherwise
- Return type:
Examples
>>> result = Maybe.success(42) >>> assert_maybe_success(result, 42) True >>> assert_maybe_success(result, 43) False
- valid8r.testing.assertions.assert_maybe_failure(result, expected_error)[source]
Assert that a Maybe is a Failure with the expected error message.
- Parameters:
result (valid8r.core.maybe.Maybe[T]) – The Maybe instance to check
expected_error (str) – The expected error message inside the Maybe
- Returns:
True if result is a Failure with the expected error, False otherwise
- Return type:
Examples
>>> result = Maybe.failure("Invalid input") >>> assert_maybe_failure(result, "Invalid input") True >>> assert_maybe_failure(result, "Other error") False