{"id":5044,"library":"robotframework-assertion-engine","title":"Robot Framework Assertion Engine","description":"Robot Framework Assertion Engine (version 4.0.0) provides a generic way to create meaningful and easy-to-use assertions for Robot Framework libraries. It is a spin-off from the Browser library project and offers a robust set of operators and formatters for in-keyword validation. The library is actively maintained with regular releases, including minor and major version updates to support new Robot Framework versions and introduce breaking changes.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/MarketSquare/AssertionEngine","tags":["robotframework","testing","assertions","test automation"],"install":[{"cmd":"pip install robotframework-assertion-engine","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for creating and running Robot Framework tests and libraries.","package":"robotframework","optional":false}],"imports":[{"note":"The primary class to instantiate for performing assertions within custom Robot Framework libraries.","symbol":"AssertionEngine","correct":"from AssertionEngine import AssertionEngine"},{"note":"An Enum defining various assertion operators, useful for structured code or type hinting when defining keywords.","symbol":"AssertionOperator","correct":"from AssertionEngine import AssertionOperator"}],"quickstart":{"code":"import os\nfrom AssertionEngine import AssertionEngine\n\nclass MyAssertions:\n\n    def __init__(self):\n        self._assertion_engine = AssertionEngine()\n\n    def my_custom_assert_keyword(self, actual_value, operator, expected_value, message=\"\"):\n        \"\"\"\n        Performs an assertion using the AssertionEngine.\n\n        Example:\n        | My Custom Assert Keyword | hello | == | hello |\n        \"\"\"\n        print(f\"Performing assertion: '{actual_value}' {operator} '{expected_value}'\")\n        self._assertion_engine.verify_assertion(\n            actual_value=actual_value,\n            assertion_operator=operator,\n            assertion_expected=expected_value,\n            message=message\n        )\n\n    def verify_length(self, value, operator, expected_length):\n        \"\"\"\n        Verifies the length of a string or list.\n\n        Example:\n        | Verify Length | ${MY_LIST} | > | 3 |\n        \"\"\"\n        actual_length = len(value)\n        print(f\"Verifying length of '{value}' (actual: {actual_length}) {operator} {expected_length}\")\n        self._assertion_engine.verify_assertion(\n            actual_value=actual_length,\n            assertion_operator=operator,\n            assertion_expected=int(expected_length),\n            message=f\"Length of '{value}'\"\n        )\n\n# To run with Robot Framework, save the above as 'MyAssertions.py'\n# and create a .robot file like this:\n#\n# *** Settings ***\n# Library    MyAssertions.py\n#\n# *** Variables ***\n# ${MY_LIST}    ${{ [1, 2, 3, 4, 5] }}\n#\n# *** Test Cases ***\n# Test String Equality\n#     My Custom Assert Keyword    hello    ==    hello\n#\n# Test String Inequality\n#     My Custom Assert Keyword    world    !=    robot\n#\n# Test Length Greater Than\n#     Verify Length    ${MY_LIST}    >    3\n#\n# Test Length Equal To\n#     Verify Length    Python    ==    6\n","lang":"python","description":"This quickstart demonstrates how to integrate `robotframework-assertion-engine` into a custom Python library for Robot Framework. The `MyAssertions` class instantiates `AssertionEngine` and exposes keywords like `My Custom Assert Keyword` and `Verify Length` that utilize the engine's `verify_assertion` method. This allows library developers to easily add a wide range of assertions directly within their Python keywords, which can then be called from Robot Framework test cases."},"warnings":[{"fix":"Review your custom library's scope management and adjust it to directly handle scope definitions without relying on AssertionEngine's previous keyword-based mechanism.","message":"Version 3.0.0 introduced backwards incompatible changes to how scopes are defined. Scoping is now entirely managed by the library maintainer, and AssertionEngine no longer provides a keyword for scope definition.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Adjust any automated parsing or expectations of error log formats, as string representations will now be more explicit (e.g., `\\n` instead of a newline character).","message":"Version 2.0.0 changed the logging of string error messages. Instead of plain text, strings are now converted using `repr()` to a printable representation, which includes Unicode values for whitespace characters. This can alter the appearance of error messages in logs.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure `robotframework-browser` is updated to a compatible version (e.g., v17.0.0 or newer), or pin `robotframework-assertion-engine` to version `2.0.0` if `robotframework-browser` cannot be updated.","message":"AssertionEngine v3.0.0 caused compatibility issues with `robotframework-browser` v16.0.0 (and Robot Framework 6.1.1) due to changes in the `Formatter()` constructor. This could lead to `TypeError: Formatter() takes no arguments` errors during library initialization.","severity":"gotcha","affected_versions":"3.0.0 - 3.x.x (when used with older `robotframework-browser` versions)"},{"fix":"Upgrade your Python environment to 3.10 or a newer supported version.","message":"Python 3.7 support was dropped in version 1.1.0. The library currently requires Python 3.10 or newer.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}