Skip to content

Commit

Permalink
Add equals operator
Browse files Browse the repository at this point in the history
  • Loading branch information
aaltat committed Aug 24, 2023
1 parent a9d0453 commit 4dac716
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
29 changes: 15 additions & 14 deletions assertionengine/assertion_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"AssertionOperator",
{
"equal": "==",
"equals": "==",
"==": "==",
"should be": "==",
"inequal": "!=",
Expand Down Expand Up @@ -56,20 +57,20 @@
AssertionOperator.__doc__ = """
Currently supported assertion operators are:
| = Operator = | = Alternative Operators = | = Description = | = Validate Equivalent = |
| ``==`` | ``equal``, ``should be`` | Checks if returned value is equal to expected value. | ``value == expected`` |
| ``!=`` | ``inequal``, ``should not be`` | Checks if returned value is not equal to expected value. | ``value != expected`` |
| ``>`` | ``greater than`` | Checks 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 than`` | Checks if returned value is less than expected value. | ``value < expected`` |
| ``<=`` | | Checks if returned value is less than or equal to expected value. | ``value <= expected`` |
| ``*=`` | ``contains`` | Checks if returned value contains expected value as substring. | ``expected in value`` |
| | ``not contains`` | Checks if returned value does not contain expected value as substring. | ``expected in value`` |
| ``^=`` | ``should start with``, ``starts`` | Checks if returned value starts with expected value. | ``re.search(f"^{expected}", value)`` |
| ``$=`` | ``should end with``, ``ends`` | Checks if returned value ends with expected value. | ``re.search(f"{expected}$", value)`` |
| ``matches`` | | Checks if given RegEx matches minimum once in returned value. | ``re.search(expected, value)`` |
| ``validate`` | | Checks if given Python expression evaluates to ``True``. | |
| ``evaluate`` | ``then`` | When using this operator, the keyword does return the evaluated Python expression. | |
| = Operator = | = Alternative Operators = | = Description = | = Validate Equivalent = |
| ``==`` | ``equal``, ``equals``, ``should be`` | Checks if returned value is equal to expected value. | ``value == expected`` |
| ``!=`` | ``inequal``, ``should not be`` | Checks if returned value is not equal to expected value. | ``value != expected`` |
| ``>`` | ``greater than`` | Checks 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 than`` | Checks if returned value is less than expected value. | ``value < expected`` |
| ``<=`` | | Checks if returned value is less than or equal to expected value. | ``value <= expected`` |
| ``*=`` | ``contains`` | Checks if returned value contains expected value as substring. | ``expected in value`` |
| | ``not contains`` | Checks if returned value does not contain expected value as substring. | ``expected in value`` |
| ``^=`` | ``should start with``, ``starts`` | Checks if returned value starts with expected value. | ``re.search(f"^{expected}", value)`` |
| ``$=`` | ``should end with``, ``ends`` | Checks if returned value ends with expected value. | ``re.search(f"{expected}$", value)`` |
| ``matches`` | | Checks if given RegEx matches minimum once in returned value. | ``re.search(expected, value)`` |
| ``validate`` | | Checks if given Python expression evaluates to ``True``. | |
| ``evaluate`` | ``then`` | When using this operator, the keyword does return the evaluated Python expression. | |
Currently supported formatters for assertions are:
| = Formatter = | = Description = |
Expand Down
1 change: 1 addition & 0 deletions atest/assertion_equal.robot
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Setting Assertion Formatters For Not Existing Formatter Should Fail
Values Are Equal
Is Equal 1 == 1
Is Equal As Number 1 == ${1}
Is Equal One Equals One

Values Are Equal With Formatter
Set Assertion Formatters {"Is Equal": ["strip", "normalize spaces"]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<enum 'AssertionOperator'>
equal::::AssertionOperator.equal
equals::::AssertionOperator.equal
==::::AssertionOperator.equal
should be::::AssertionOperator.equal
inequal::::AssertionOperator.inequal
Expand Down

0 comments on commit 4dac716

Please sign in to comment.