Skip to content

Commit 41f09ef

Browse files
committed
Explicit tests for Should Match bug with newlines.
Bug itself is already fixed as a side-effect of PR robotframework#2560. Fixes robotframework#2894.
1 parent d2a4928 commit 41f09ef

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

atest/robot/standard_libraries/builtin/should_match.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Resource builtin_resource.robot
66
Should Match
77
Check test case ${TESTNAME}
88

9+
Should Match with extra trailing newline
10+
Check test case ${TESTNAME}
11+
912
Should Match case-insensitive
1013
Check test case ${TESTNAME}
1114

atest/testdata/standard_libraries/builtin/should_match.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ Should Match
88
abcdefghijklmnopqrstuvwxyz *
99
abcdefghijklmnopqrstuvwxyz ?*?efg*p*t?vw*z
1010
NOK ???
11+
foo\n foo\n
1112
NOK H*K Failure
1213

14+
Should Match with extra trailing newline
15+
[Template] Run Keyword And Expect Error
16+
'foo\n' does not match 'foo' Should Match foo\n foo
17+
'foo' does not match 'foo\n' Should Match foo foo\n
18+
1319
Should Match case-insensitive
1420
[Template] Should Match
1521
Hello! heLLo! ignore_case=True
@@ -26,6 +32,8 @@ Should Not Match
2632
[Template] Should Not Match
2733
this string does not match this pattern
2834
Case matters case matters
35+
foo\n foo
36+
foo foo\n
2937
Hello world ?ello*
3038

3139
Should Not Match case-insensitive

utest/utils/test_match.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ def test_glob_pattern_with_brackets_not_in_range(self):
121121
pattern = 'Weird*[[!name]]'
122122
self._matches('Weird my[game]', pattern)
123123

124+
def test_spaceless(self):
125+
for text in ['fbar', 'foobar']:
126+
assert Matcher('f*bar').match(text)
127+
assert Matcher('f * b a r').match(text)
128+
assert Matcher('f*bar', spaceless=False).match(text)
129+
for text in ['f b a r', 'f o o b a r', ' foo bar ', 'fbar\n']:
130+
assert Matcher('f*bar').match(text)
131+
assert not Matcher('f*bar', spaceless=False).match(text)
132+
124133
def _matches(self, string, pattern, **config):
125134
assert Matcher(pattern, **config).match(string), pattern
126135

0 commit comments

Comments
 (0)