Skip to content

Commit

Permalink
Add support for case insensitive formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
aaltat committed Aug 19, 2023
1 parent e4dafe3 commit 9f8de22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions assertionengine/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ def _apply_to_expected(value: str) -> str:
return value


def _case_insensitive(value: str) -> str:
return value.lower()


FormatRules = {
"normalize spaces": _normalize_spaces,
"strip": _strip,
"apply to expected": _apply_to_expected,
"case insensitive": _case_insensitive,
}


Expand Down
11 changes: 11 additions & 0 deletions atest/assertion_equal.robot
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ Values Are Equal With Formatter
Is Equal ${SPACE}${SPACE}1${SPACE}${SPACE}1${SPACE}1${SPACE}${SPACE} equal
... 1${SPACE}1${SPACE}1

Values Are Equal With Case Insensitive Formatter
Set Assertion Formatters {"Is Equal": ["case insensitive"]}
Is Equal FOOBAR equal foobar
TRY
Is Equal FOOBAR equal foobaR
EXCEPT Prefix message 'foobar' (str) should be 'foobaR' (str)
Log Error Message Correct
END
Set Assertion Formatters {"Is Equal": ["case insensitive", "apply to expected"]}
Is Equal FOOBAR equal foobaR

Values Are Equal With Formatter For Expected
Set Assertion Formatters {"Is Equal": ["strip", "apply to expected"]}
Is Equal 1${SPACE}1${SPACE}1 equal
Expand Down

0 comments on commit 9f8de22

Please sign in to comment.