Revision: 627f3e7bd090
Branch: default
Author: Pekka Klärck
Date: Fri Oct 25 15:11:00 2013 UTC
Log: String.Split String From Right: Fixed handling longer separators
Update issue 1553
Status: Done
Owner: pekka.klarck
Labels: bwic
Thanks for the report. Easiest solution was using rsplit as you suggested.
This was clearly not too well tested because such a bug was lurking
here. Apparently this keyword isn't used too often with longer
separators either as nobody had spotted the bug earlier. Or
alternatively they have decided to reverse the separator. In that case
this fix is backwards incompatible for them. I added `bwic` label so
that we remember to mention this in 2.8.2 release notes.
http://code.google.com/p/robotframework/source/detail?r=627f3e7bd090
Modified:
/atest/robot/standard_libraries/string/split_string.txt
/atest/testdata/standard_libraries/string/split_string.txt
/src/robot/libraries/String.py
=======================================
--- /atest/robot/standard_libraries/string/split_string.txt Tue Dec 20
11:52:53 2011 UTC
+++ /atest/robot/standard_libraries/string/split_string.txt Fri Oct 25
15:11:00 2013 UTC
@@ -6,6 +6,9 @@
*** Test Cases ***
Split String
Check Test Case ${TESTNAME}
+
+Split String With Longer Separator
+ Check Test Case ${TESTNAME}
Split String With Whitespaces and Separator Is None
Check Test Case ${TESTNAME}
@@ -30,6 +33,9 @@
Split String From Right
Check Test Case ${TESTNAME}
+
+Split String From Right With Longer Separator
+ Check Test Case ${TESTNAME}
Split String From Right With Whitespaces and Separator Is None
Check Test Case ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/string/split_string.txt Tue Feb 12
12:35:28 2013 UTC
+++ /atest/testdata/standard_libraries/string/split_string.txt Fri Oct 25
15:11:00 2013 UTC
@@ -10,6 +10,10 @@
${result} = Split String ${NSN} _
Result Should Contain Items In Given Order ${result} nokia
siemens networks
+Split String With Longer Separator
+ ${result} = Split String 1abc2abc3 abc
+ Result Should Contain Items In Given Order ${result} 1 2 3
+
Split String With Whitespaces and Separator Is None
${result} = Split String ${WHITE SPACES}
Result Should Contain Items In Given Order ${result} hello
world again
@@ -42,6 +46,10 @@
${result} = Split String From Right ${NSN} _
Result Should Contain Items In Given Order ${result} nokia
siemens networks
+Split String From Right With Longer Separator
+ ${result} = Split String From Right 1abc2abc3 abc
+ Result Should Contain Items In Given Order ${result} 1 2 3
+
Split String From Right With Whitespaces and Separator Is None
${result} = Split String From Right ${WHITE SPACES}
Result Should Contain Items In Given Order ${result} hello
world again
=======================================
--- /src/robot/libraries/String.py Thu Oct 3 12:41:20 2013 UTC
+++ /src/robot/libraries/String.py Fri Oct 25 15:11:00 2013 UTC
@@ -348,12 +348,13 @@
an effect only when `max_split` is given.
Examples:
- | ${first} | ${others} = | Split String | ${string} | - | 1 |
- | ${others} | ${last} = | Split String From Right | ${string} | -
| 1 |
+ | ${first} | ${rest} = | Split String | ${string} | - |
1 |
+ | ${rest} | ${last} = | Split String From Right | ${string} | - |
1 |
"""
- # Strings in Jython 2.2 don't have 'rsplit' methods
- reversed = self.split_string(string[::-1], separator, max_split)
- return [ r[::-1] for r in reversed ][::-1]
+ if separator == '':
+ separator = None
+ max_split = self._convert_to_integer(max_split, 'max_split')
+ return string.rsplit(separator, max_split)
def split_string_to_characters(self, string):
"""Splits the string` to characters.
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.