Python strop.replace() Examples

The following are 6 code examples of strop.replace(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module strop , or try the search function .
Example #1
Source File: test_strop.py    From BinderFilter with MIT License 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assertTrue(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assertTrue(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assertTrue(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!") 
Example #2
Source File: test_strop.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assertTrue(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assertTrue(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assertTrue(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!") 
Example #3
Source File: test_strop.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assertTrue(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assertTrue(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assertTrue(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!") 
Example #4
Source File: test_strop.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assert_(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assert_(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assert_(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assert_(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assert_(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assert_(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assert_(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assert_(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!") 
Example #5
Source File: test_strop.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assertTrue(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assertTrue(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assertTrue(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!") 
Example #6
Source File: test_strop.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def test_replace(self):
        replace = strop.replace
        self.assertTrue(replace("one!two!three!", '!', '@', 1)
                     == "one@two!three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 2)
                     == "one@two@three!")
        self.assertTrue(replace("one!two!three!", '!', '@', 3)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@', 4)
                     == "one@two@three@")

        # CAUTION: a replace count of 0 means infinity only to strop,
        # not to the string .replace() method or to the
        # string.replace() function.

        self.assertTrue(replace("one!two!three!", '!', '@', 0)
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", '!', '@')
                     == "one@two@three@")
        self.assertTrue(replace("one!two!three!", 'x', '@')
                     == "one!two!three!")
        self.assertTrue(replace("one!two!three!", 'x', '@', 2)
                     == "one!two!three!")