Package: robotframework-assertion-engine
Generic way to create meaningful and easy to use assertions for theRobot Frameworklibraries. This tools is spin off fromBrowser libraryproject, where the Assertion
Engine was developed as part of the of library.Supported AssertionsCurrently supported assertion operators are:OperatorAlternative OperatorsDescriptionValidate Equivalent==equal, equals, should beChecks if returned value is equal to expected value.value == expected!=inequal, should not beChecks if returned value is not equal to expected value.value != expected>greater thanChecks if returned value is greater than expected value.value > expected>=Checks if returned value is greater than or equal to expected value.value >= expected<less thanChecks if returned value is less than expected value.value < expected<=Checks if returned value is less than or equal to expected value.value <= expected*=containsChecks if returned value contains expected value as substring.expected in valuenot containsChecks if returned value does not contain expected value as substring.expected not in value^=should start with, startsChecks if returned value starts with expected value.re.search(f”^{expected}”, value)$=should end with, endsChecks if returned value ends with expected value.re.search(f”{expected}$”, value)matchesChecks if given RegEx matches minimum once in returned value.re.search(expected, value)validateChecks if given Python expression evaluates to True.evaluatethenWhen using this operator, the keyword does return the evaluated Python expression.Supported formatters:FormatterDescriptionnormalize spacesSubstitutes multiple spaces to single space from the valuestripRemoves spaces from the beginning and end of the valueapply to expectedApplies rules also for the expected valuecase insensitiveConverts value to lower caseUsageWhen library developers wants to do an assertion inline with the keyword call, then AssertionEngine provides
automatic validation within single keyword call. Keyword method should get value, example from page, database
or from anything which the library interacts and then useverify_assertionmethod from AssertionEngine to
perform the validation. Theverify_assertionmethods needs three things to perform the assertion:valuefrom the system,assertion_operatorhow  the validation is performed andassertion_expectedwhich
represent the expected value. It is also possible to provide custom error message and prefix the default error
message.Example library can contain keyword:def keyword(
    arg_to_get_value: str,
    assertion_operator: Optional[AssertionOperator] = None,
    assertion_expected: Any = None,
    message: str = None,
):
    value = method_to_get_value(arg_to_get_value)
    return verify_assertion(
        value,
        assertion_operator,
        assertion_expected,
        "Prefix message",
        message,
    )AssertionEngine provides an interface to define scope for the formatters, but because scoping is a library
specific implementation, it is up to the library to decide how scoping is actually implemented. AssertionEngine
Formatter class is anABCwhich providesget_formatterandset_formatterinterface methods for library developers. The AssertionEngineatestlibraries has examples how interface
can be implemented in practice.