Skip to content

Commit 514f7cf

Browse files
authored
BuiltIn: Add strip_spaces to various comparison keyowrds (robotframework#3843)
Fixes robotframework#3240.
1 parent b0cd551 commit 514f7cf

17 files changed

+739
-27
lines changed

atest/robot/standard_libraries/builtin/count.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Should Contain X Times failing
3535
Should Contain X Times case-insensitive
3636
Check test case ${TESTNAME}
3737

38+
Should Contain X Times without leading spaces
39+
Check test case ${TESTNAME}
40+
41+
Should Contain X Times without trailing spaces
42+
Check test case ${TESTNAME}
43+
44+
Should Contain X Times without leading and trailing spaces
45+
Check test case ${TESTNAME}
46+
3847
Should Contain X Times with invalid item
3948
Check test case ${TESTNAME}
4049

atest/robot/standard_libraries/builtin/should_be_equal.robot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ Basics
1414
Case-insensitive
1515
Check Test Case ${TESTNAME}
1616

17+
Without leading spaces
18+
Check Test Case ${TESTNAME}
19+
20+
Without trailing spaces
21+
Check Test Case ${TESTNAME}
22+
23+
Without leading and trailing spaces
24+
Check Test Case ${TESTNAME}
25+
1726
Fails with values
1827
Check test case ${TESTNAME}
1928

@@ -93,6 +102,15 @@ Should Not Be Equal
93102
Should Not Be Equal case-insensitive
94103
Check Test Case ${TESTNAME}
95104

105+
Should Not Be Equal without leading spaces
106+
Check Test Case ${TESTNAME}
107+
108+
Should Not Be Equal without trailing spaces
109+
Check Test Case ${TESTNAME}
110+
111+
Should Not Be Equal without leading and trailing spaces
112+
Check Test Case ${TESTNAME}
113+
96114
Should Not Be Equal with bytes containing non-ascii characters
97115
${tc}= Check test case ${TESTNAME}
98116
Verify argument type message ${tc.kws[0].msgs[0]} bytes bytes

atest/robot/standard_libraries/builtin/should_be_equal_as_xxx.robot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Should Be Equal As Strings does NFC normalization
4141
Should Be Equal As Strings case-insensitive
4242
Check test case ${TESTNAME}
4343

44+
Should Be Equal As Strings without leading spaces
45+
Check test case ${TESTNAME}
46+
47+
Should Be Equal As Strings without trailing spaces
48+
Check test case ${TESTNAME}
49+
50+
Should Be Equal As Strings without leading and trailing spaces
51+
Check test case ${TESTNAME}
52+
4453
Should Be Equal As Strings repr
4554
Check test case ${TESTNAME}
4655

@@ -56,3 +65,12 @@ Should Not Be Equal As Strings
5665

5766
Should Not Be Equal As Strings case-insensitive
5867
Check test case ${TESTNAME}
68+
69+
Should Not Be Equal As Strings without leading spaces
70+
Check test case ${TESTNAME}
71+
72+
Should Not Be Equal As Strings without trailing spaces
73+
Check test case ${TESTNAME}
74+
75+
Should Not Be Equal As Strings without leading and trailing spaces
76+
Check test case ${TESTNAME}

atest/robot/standard_libraries/builtin/should_contain.robot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ Should Contain with non-strings
1212
Should Contain case-insensitive
1313
Check Test Case ${TESTNAME}
1414

15+
Should Contain without leading spaces
16+
Check Test Case ${TESTNAME}
17+
18+
Should Contain without trailing spaces
19+
Check Test Case ${TESTNAME}
20+
21+
Should Contain without leading and trailing spaces
22+
Check Test Case ${TESTNAME}
23+
1524
Should Not Contain
1625
Check test case ${TESTNAME}
1726

@@ -20,3 +29,12 @@ Should Not Contain with non-strings
2029

2130
Should Not Contain case-insensitive
2231
Check Test Case ${TESTNAME}
32+
33+
Should Not Contain without leading spaces
34+
Check Test Case ${TESTNAME}
35+
36+
Should Not Contain without trailing spaces
37+
Check Test Case ${TESTNAME}
38+
39+
Should Not Contain without leading and trailing spaces
40+
Check Test Case ${TESTNAME}

atest/robot/standard_libraries/builtin/should_contain_any.robot

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ Should Contain Any without items fails
1515
Should Contain Any case-insensitive
1616
Check test case ${TESTNAME}
1717

18+
Should Contain Any without leading spaces
19+
Check test case ${TESTNAME}
20+
21+
Should Contain Any without trailing spaces
22+
Check test case ${TESTNAME}
23+
24+
Should Contain Any without leading and trailing spaces
25+
Check test case ${TESTNAME}
26+
1827
Should Contain Any with invalid configuration
1928
Check test case ${TESTNAME}
2029

@@ -30,5 +39,14 @@ Should Not Contain Any without items fails
3039
Should Not Contain Any case-insensitive
3140
Check test case ${TESTNAME}
3241

42+
Should Not Contain Any without leading spaces
43+
Check test case ${TESTNAME}
44+
45+
Should Not Contain Any without trailing spaces
46+
Check test case ${TESTNAME}
47+
48+
Should Not Contain Any without leading and trailing spaces
49+
Check test case ${TESTNAME}
50+
3351
Should Not Contain Any with invalid configuration
3452
Check test case ${TESTNAME}

atest/robot/standard_libraries/builtin/should_xxx_with.robot

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,45 @@ Should Start With case-insensitive
1212
Should Start With without values
1313
Check test case ${TESTNAME}
1414

15+
Should Start With without leading spaces
16+
Check test case ${TESTNAME}
17+
18+
Should Start With without trailing spaces
19+
Check test case ${TESTNAME}
20+
21+
Should Start With without leading and trailing spaces
22+
Check test case ${TESTNAME}
23+
1524
Should Not Start With
1625
Check test case ${TESTNAME}
1726

1827
Should Not Start With case-insensitive
1928
Check test case ${TESTNAME}
2029

30+
Should Not Start With without leading spaces
31+
Check test case ${TESTNAME}
32+
33+
Should Not Start With without trailing spaces
34+
Check test case ${TESTNAME}
35+
36+
Should Not Start With without leading and trailing spaces
37+
Check test case ${TESTNAME}
38+
2139
Should End With
2240
Check test case ${TESTNAME}
2341

2442
Should End With case-insensitive
2543
Check test case ${TESTNAME}
2644

45+
Should End With without leading spaces
46+
Check test case ${TESTNAME}
47+
48+
Should End With without trailing spaces
49+
Check test case ${TESTNAME}
50+
51+
Should End With without leading and trailing spaces
52+
Check test case ${TESTNAME}
53+
2754
Should End With without values
2855
Check test case ${TESTNAME}
2956

@@ -32,3 +59,12 @@ Should Not End With
3259

3360
Should Not End With case-insensitive
3461
Check test case ${TESTNAME}
62+
63+
Should Not End With without leading spaces
64+
Check test case ${TESTNAME}
65+
66+
Should Not End With without trailing spaces
67+
Check test case ${TESTNAME}
68+
69+
Should Not End With without leading and trailing spaces
70+
Check test case ${TESTNAME}

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 6 arguments, got 1.
13+
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 7 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
@@ -112,7 +112,7 @@ Invalid syntax in UK
112112

113113
Multiple Failures
114114
[Documentation] FAIL Several failures occurred:\n\n
115-
... 1) Keyword 'BuiltIn.Should Be Equal' expected 2 to 6 arguments, got 1.\n\n
115+
... 1) Keyword 'BuiltIn.Should Be Equal' expected 2 to 7 arguments, got 1.\n\n
116116
... 2) Invalid argument specification: Invalid argument syntax '${arg'.\n\n
117117
... 3) Keyword 'Some Return Value' expected 2 arguments, got 3.\n\n
118118
... 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
@@ -327,8 +327,8 @@ Templated test with for loop continues after keyword timeout
327327
END
328328

329329
Templated test ends after syntax errors
330-
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 6 arguments, got 7.
331-
Syntax error makes test end again here
330+
[Documentation] FAIL Keyword 'BuiltIn.Should Be Equal' expected 2 to 7 arguments, got 8.
331+
The syntax error makes test end again here
332332
Not compared anymore
333333

334334
Templated test continues after variable error

atest/testdata/standard_libraries/builtin/count.robot

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,34 @@ Should Contain X Times case-insensitive
5858
${DICT} Ä 2 ignore_case=yes
5959
${DICT 1} a 100 ignore_case=yes, please
6060

61+
Should Contain X Times without leading spaces
62+
[Documentation] FAIL '${DICT_5}' contains 'b' 1 time, not 2 times.
63+
a\ \ a\ \ a \ a 2 strip_spaces=False
64+
a\ \ a\ \ a \ a 3 strip_spaces=Leading
65+
${DICT_5} \n\na 2 strip_spaces=Leading
66+
${DICT_5} \ b 1 strip_spaces=leading
67+
${DICT_5} \nb 2 strip_spaces=LEADING
68+
${LIST_4} \ a 2 strip_spaces=LEADING
69+
70+
Should Contain X Times without trailing spaces
71+
[Documentation] FAIL '${DICT_5}' contains 'd' 1 time, not 2 times.
72+
a\ \ a\ \ a a${SPACE} 2 strip_spaces=No
73+
a\ \ a\ \ a a${SPACE} 3 strip_spaces=TRailing
74+
${DICT_5} a\t 1 strip_spaces=Trailing
75+
${DICT_5} d\n 1 strip_spaces=TRAILING
76+
${DICT_5} d\t\t 2 strip_spaces=trailing
77+
${LIST_4} b\n\n 2 strip_spaces=trailing
78+
79+
Should Contain X Times without leading and trailing spaces
80+
[Documentation] FAIL '${LIST_4}' contains 'c' 1 time, not 0 times.
81+
a\ \ a\ \ a \ a${SPACE} 1 strip_spaces=No
82+
a\ \ a\ \ a \ a${SPACE} 3 strip_spaces=Yes
83+
${DICT_5} \n a\t 3 strip_spaces=sure
84+
${DICT_5} \ d\n 2 strip_spaces=TRUE
85+
${DICT_5} \ d\t 2 strip_spaces=true
86+
${LIST_4} \ b\n 2 strip_spaces=${True}
87+
${LIST_4} c 0 strip_spaces=sure thing
88+
6189
Should Contain X Times with invalid item
6290
[Documentation] FAIL STARTS: Converting '10' to list failed: TypeError:
6391
${10} a 1

atest/testdata/standard_libraries/builtin/should_be_equal.robot

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ Case-insensitive
1818
${42} ${42} ignore_case=True
1919
Yötä Päivää ignore_case=yep!
2020

21+
Without leading spaces
22+
[Documentation] FAIL test != value
23+
${SPACE}test test strip_spaces=leading
24+
hyvää yötä \nhyvää yötä repr=True strip_spaces=Leading
25+
\t${42} \t${42} strip_spaces=LEADING
26+
\ntest \n value strip_spaces=leading
27+
28+
Without trailing spaces
29+
[Documentation] FAIL test != value
30+
test${SPACE} test strip_spaces=trailing
31+
hyvää yötä hyvää yötä\t repr=True strip_spaces=Trailing
32+
${42}\t ${42}\n strip_spaces=TRAILING
33+
test\n value\t strip_spaces=trailing
34+
35+
Without leading and trailing spaces
36+
[Documentation] FAIL test != value
37+
test${SPACE} test strip_spaces=True
38+
hyvää yötä hyvää yötä\t repr=True strip_spaces=TRUE
39+
${SPACE}${42}\n ${SPACE}${42}\t strip_spaces=yeS
40+
\n\ test\t ${SPACE}value\n strip_spaces=yes
41+
2142
Fails with values
2243
[Documentation] FAIL Several failures occurred:
2344
...
@@ -307,6 +328,48 @@ Should Not Be Equal case-insensitive
307328
HYVÄÄ YÖTÄ hyvää yötä1 ignore_case=True
308329
foo FOO ignore_case=True
309330

331+
Should Not Be Equal without leading spaces
332+
[Documentation] FAIL Several failures occurred:
333+
...
334+
... 1) test == test
335+
...
336+
... 2) repr=True: hyvää yötä == hyvää yötä
337+
...
338+
... 3) 42 == 42
339+
[Template] Should Not Be Equal
340+
${SPACE}test test strip_spaces=leading
341+
hyvää yötä \nhyvää yötä repr=True strip_spaces=Leading
342+
\t${42} \t${42} strip_spaces=LEADING
343+
\t\ntest \n\tvalue strip_spaces=leading
344+
345+
Should Not Be Equal without trailing spaces
346+
[Documentation] FAIL Several failures occurred:
347+
...
348+
... 1) test == test
349+
...
350+
... 2) repr=True: hyvää yötä == hyvää yötä
351+
...
352+
... 3) 42 == 42
353+
[Template] Should Not Be Equal
354+
test${SPACE} test strip_spaces=trailing
355+
hyvää yötä hyvää yötä\t repr=True strip_spaces=Trailing
356+
${42}\n\t ${42}${SPACE} strip_spaces=TRAILING
357+
test\t\n value \n strip_spaces=TraIling
358+
359+
Should Not Be Equal without leading and trailing spaces
360+
[Documentation] FAIL Several failures occurred:
361+
...
362+
... 1) test == test
363+
...
364+
... 2) repr=True: hyvää yötä == hyvää yötä
365+
...
366+
... 3) 42 == 42
367+
[Template] Should Not Be Equal
368+
test${SPACE} test strip_spaces=True
369+
hyvää yötä hyvää yötä\t repr=True strip_spaces=TRUE
370+
\t${42}\t\n \n${42}\t\n strip_spaces=true
371+
\ test\t\n \tvalue\t strip_spaces=yeS
372+
310373
Should Not Be Equal with bytes containing non-ascii characters
311374
[Documentation] FAIL ${BYTES WITH NON ASCII} == ${BYTES WITH NON ASCII}
312375
[Template] Should Not Be Equal

0 commit comments

Comments
 (0)