Пример #1
0
    def testReplace(self):
        """
        Tests Wire.replace()
        Tests with:
        - Wire.replace(old, new, count=1)
        - Wire.replace(old, new, count=2)
        - Wire.replace(old, new, count=None)
        """
        wire = Wire("Testing 1 2 3 Testing 1 2 3")
        wire = wire.replace("Testing", "Success", count=1)
        self.assertEqual(wire, "Success 1 2 3 Testing 1 2 3")

        wire = Wire("Testing 1 2 3 Testing 1 2 3 Testing")
        wire = wire.replace("Testing", "Success", count=2)
        self.assertEqual(wire, "Success 1 2 3 Success 1 2 3 Testing")

        wire = Wire("Testing Testing Testing 1 2 3 Testing")
        wire = wire.replace("Testing", "Success", count=None)
        self.assertEqual(wire, "Success Success Success 1 2 3 Success")