Revision: 0b838bece1c0
Branch: default
Author: Janne Piironen <janne.piiro...@gmail.com>
Date: Mon Sep 30 11:41:32 2013 UTC
Log: Added Remove From String and Remove From String Using Regexp
keywords
update issue 1491
http://code.google.com/p/robotframework/source/detail?r=0b838bece1c0
Added:
/atest/robot/standard_libraries/string/remove_from_string.txt
/atest/testdata/standard_libraries/string/remove_from_string.txt
Modified:
/src/robot/libraries/String.py
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/string/remove_from_string.txt Mon Sep
30 11:41:32 2013 UTC
@@ -0,0 +1,29 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY}
standard_libraries/string/remove_from_string.txt
+Force Tags pybot jybot regression
+Resource atest_resource.txt
+
+*** Test Cases ***
+Remove From String
+ Check Test Case ${TESTNAME}
+
+Remove From String Non-ASCII characters
+ Check Test Case ${TESTNAME}
+
+Remove From String Not Found
+ Check Test Case ${TESTNAME}
+
+Remove From String With Count 0
+ Check Test Case ${TESTNAME}
+
+Remove From String When Count Is Invalid
+ Check Test Case ${TESTNAME}
+
+Remove From String Using Regexp
+ Check Test Case ${TESTNAME}
+
+Remove From String Using Regexp Not Found
+ Check Test Case ${TESTNAME}
+
+Remove From String Using Regexp When Count Is Invalid
+ Check Test Case ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/string/remove_from_string.txt Mon
Sep 30 11:41:32 2013 UTC
@@ -0,0 +1,39 @@
+*** Settings ***
+Library String
+
+*** Test Cases ***
+Remove From String
+ ${result} = Remove From String RobotFramework o
+ Should Be Equal ${result} RbtFramewrk
+ ${result} = Remove From String RobotFramework o 2
+ Should Be Equal ${result} RbtFramework
+
+Remove From String Non-ASCII characters
+ ${result} = Remove From String Robot\u2603Framew\u2603ork
\u2603
+ Should Be Equal ${result} RobotFramework
+ ${result} = Remove From String R\x00obotFramework \x00
+ Should Be Equal ${result} RobotFramework
+
+Remove From String Not Found
+ ${result} = Remove From String Robot bit
+ Should Be Equal ${result} Robot
+
+Remove From String With Count 0
+ ${result} = Remove From String Robot o 0
+ Should Be Equal ${result} Robot
+
+Remove From String When Count Is Invalid
+ [Documentation] FAIL ValueError: Cannot convert 'count'
argument 'invalid' to an integer.
+ ${result} = Remove From String Robot Framework o invalid
+
+Remove From String Using Regexp Not Found
+ ${result} = Remove From String Using Regexp Robot Framework
Fnot.*k
+ Should be equal ${result} Robot Framework
+
+Remove From String Using Regexp
+ ${result} = Remove From String Using Regexp RobotFramework
F.*k
+ Should Be Equal ${result} Robot
+
+Remove From String Using Regexp When Count Is Invalid
+ [Documentation] FAIL ValueError: Cannot convert 'count'
argument 'invalid' to an integer.
+ Remove From String Using Regexp Robot Framework .* invalid
=======================================
--- /src/robot/libraries/String.py Thu Jun 6 14:00:44 2013 UTC
+++ /src/robot/libraries/String.py Mon Sep 30 11:41:32 2013 UTC
@@ -485,6 +485,46 @@
if not string.istitle():
self._fail(msg, "'%s' is not titlecase.", string)
+ def remove_from_string(self, string, removable, count=-1):
+ """Removes `removable` in the given `string`.
+
+ `removable` is used as a literal string. See `Remove String
+ Using Regexp` if more powerful pattern matching is needed.
+
+ If the optional argument `count` is given, only that many
+ occurrences from left are replaced. Negative `count` means
+ that all occurrences are replaced (default behaviour) and zero
+ means that nothing is done.
+
+ A modified version of the string is returned and the original
+ string is not altered.
+
+ New in Robot Framework 2.8.2
+
+ Examples:
+ | ${str} = | Remove From String | ${str} | world | |
+ | ${str} = | Remove From String | ${str} | l | 2 |
+ """
+ string = self.replace_string(string, removable, '', count)
+ return string
+
+ def remove_from_string_using_regexp(self, string, pattern, count=-1):
+ """Removes `pattern` from the given `string`.
+
+ This keyword is otherwise identical to `Remove From String`, but
+ the `pattern` to search for is considered to be a regular
+ expression. See `BuiltIn.Should Match Regexp` for more
+ information about Python regular expression syntax in general
+ and how to use it in Robot Framework test data in particular.
+
+ New in Robot Framework 2.8.2
+
+ Examples:
+ | ${str} = | Remove From String Using Regexp | ${str} | (Hello|Hi)
| |
+ | ${str} = | Remove From String Using Regexp | ${str} |
20\\\\d\\\\d-\\\\d\\\\d-\\\\d\\\\d | 2 |
+ """
+ return self.replace_string_using_regexp(string, pattern, '', count)
+
def _convert_to_index(self, value, name):
if value == '':
return 0
--
---
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 robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.