Exemplo n.º 1
0
    def test_removal(self, s, chars):
        output = replace_chars(s, chars, '')

        replace_set = set(chars)
        j = 0
        for c in s:
            if c in replace_set:
                continue
            else:
                self.assertEqual(output[j], c, '%r %r %r %r' % (
                    output, replace_set, c, c in replace_set))
                j += 1
Exemplo n.º 2
0
    def test_replacement(self, s, chars, replace_with):
        output = replace_chars(s, chars, replace_with)

        replace_set = set(chars)
        j = 0
        for c in s:
            if c in replace_set:
                self.assertEqual(output[j], replace_with)
            else:
                self.assertEqual(output[j], c,
                    'from %r got %r removing %r and %r != %r' % (
                    s, output, replace_set, output[j], c))
            j += 1