Skip to content

Commit 107cd59

Browse files
committed
Should Be Equal (As Strings): Add formatter=str/repr/ascii
Also added `formatter=None` to related `robot.utils.asserts` and did little documentation and test enhancement to related code/tests. Fixes robotframework#2815.
1 parent 4710d41 commit 107cd59

File tree

11 files changed

+424
-97
lines changed

11 files changed

+424
-97
lines changed

atest/robot/standard_libraries/builtin/should_be_equal.robot

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,50 @@ Fails without values
2121
Check test case ${TESTNAME}
2222

2323
Multiline comparison uses diff
24-
Check test case ${TESTNAME}
24+
${tc} = Check test case ${TESTNAME}
25+
Check Log Message ${tc.kws[0].msgs[1]} foo\nbar\ndar\n\n!=\n\nfoo\nbar\ngar\n\ndar
2526

2627
Multiline comparison requires both multiline
2728
Check test case ${TESTNAME}
2829

2930
Multiline comparison without including values
3031
Check test case ${TESTNAME}
3132

33+
formatter=repr
34+
Check test case ${TESTNAME}
35+
36+
formatter=repr/ascii with non-ASCII characters on Python 2
37+
[Tags] require-py2
38+
Check test case ${TESTNAME}
39+
40+
formatter=repr/ascii with non-ASCII characters on Python 3
41+
[Tags] require-py3
42+
Check test case ${TESTNAME}
43+
44+
formatter=repr with multiline
45+
${tc} = Check test case ${TESTNAME}
46+
Check Log Message ${tc.kws[0].msgs[1]} foo\nbar\ndar\n\n!=\n\nfoo\nbar\ngar\n\ndar
47+
48+
formatter=repr with multiline and different line endings
49+
${tc} = Check test case ${TESTNAME}
50+
Check Log Message ${tc.kws[0].msgs[1]} 1\n2\n3\n\n!=\n\n1\n2\n3
51+
Check Log Message ${tc.kws[1].msgs[1]} 1\n2\n3\n\n!=\n\n1\n2\n3
52+
53+
formatter=repr/ascii with multiline and non-ASCII characters on Python 2
54+
[Tags] require-py2
55+
${tc} = Check test case ${TESTNAME}
56+
Check Log Message ${tc.kws[0].msgs[1]} Å\nÄ\n\Ö\n\n!=\n\nÅ\nA\u0308\n\Ö
57+
Check Log Message ${tc.kws[1].msgs[1]} Å\nÄ\n\Ö\n\n!=\n\nÅ\nA\u0308\n\Ö
58+
59+
formatter=repr/ascii with multiline and non-ASCII characters on Python 3
60+
[Tags] require-py3
61+
${tc} = Check test case ${TESTNAME}
62+
Check Log Message ${tc.kws[0].msgs[1]} Å\nÄ\n\Ö\n\n!=\n\nÅ\nA\u0308\n\Ö
63+
Check Log Message ${tc.kws[1].msgs[1]} Å\nÄ\n\Ö\n\n!=\n\nÅ\nA\u0308\n\Ö
64+
65+
Invalid formatter
66+
Check test case ${TESTNAME}
67+
3268
Tuple and list with same items fail
3369
Check test case ${TESTNAME}
3470

atest/robot/standard_libraries/builtin/should_be_equal_as_xxx.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ Should Be Equal As Strings
3535
${tc}= Check test case ${TESTNAME}
3636
Verify argument type message ${tc.kws[0].msgs[0]} int unicode
3737

38+
Should Be Equal As Strings does NFC normalization
39+
Check test case ${TESTNAME}
40+
3841
Should Be Equal As Strings case-insensitive
3942
Check test case ${TESTNAME}
4043

44+
Should Be Equal As Strings repr
45+
Check test case ${TESTNAME}
46+
4147
Should Be Equal As Strings multiline
4248
Check test case ${TESTNAME}
4349

50+
Should Be Equal As Strings repr multiline
51+
Check test case ${TESTNAME}
52+
4453
Should Not Be Equal As Strings
4554
${tc}= Check test case ${TESTNAME}
4655
Verify argument type message ${tc.kws[0].msgs[0]} unicode float

atest/testdata/cli/dryrun/args.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Valid positional args
1010
Normal and varargs and kwargs 1 2 3 4
1111

1212
Too few arguments
13-
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 5 arguments, got 1.
13+
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 6 arguments, got 1.
1414
Should Be Equal 1
1515

1616
Too few arguments for UK

atest/testdata/cli/dryrun/dryrun.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Invalid syntax in UK
113113

114114
Multiple Failures
115115
[Documentation] FAIL Several failures occurred:\n\n
116-
... 1) Keyword 'BuiltIn.Should Be Equal' expected 2 to 5 arguments, got 1.\n\n
116+
... 1) Keyword 'BuiltIn.Should Be Equal' expected 2 to 6 arguments, got 1.\n\n
117117
... 2) Invalid argument specification: Invalid argument syntax '${arg'.\n\n
118118
... 3) Keyword 'BuiltIn.Log' expected 1 to 5 arguments, got 6.\n\n
119119
... 4) No keyword with name 'Yet another non-existing keyword' found.\n\n

atest/testdata/running/test_template.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ Templated test with for loop continues after keyword timeout
243243
END
244244

245245
Templated test ends after syntax errors
246-
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 5 arguments, got 6.
247-
Syntax error makes test end again
246+
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 6 arguments, got 7.
247+
Syntax error makes test end again here
248248
Not compared anymore
249249

250250
Templated test continues after variable error

0 commit comments

Comments
 (0)