Exemplo n.º 1
0
 def test_single_backslash(self):
     for inp, exp in [ ('\\', ''),
                       ('\\ ', ' '),
                       ('a\\', 'a'),
                       ('\\a', 'a'),
                       ('a\\b\\c\\d', 'abcd') ]:
         assert_equals(unescape(inp), exp, inp)
Exemplo n.º 2
0
 def test_multiple_backslash(self):
     for inp, exp in [ ('\\\\', '\\'),
                       ('\\\\\\', '\\'),
                       ('\\\\\\\\', '\\\\'),
                       ('x\\\\x', 'x\\x'),
                       ('x\\\\\\x', 'x\\x'),
                       ('x\\\\\\\\x', 'x\\\\x') ]:
         assert_equals(unescape(inp), exp, inp)
Exemplo n.º 3
0
 def test_tab(self):
     for inp, exp in [ ('\\t', '\t'),
                       ('\\\\t', '\\t'),
                       ('\\\\\\t', '\\\t'),
                       ('\\t ', '\t '),
                       ('\\\\t ', '\\t '),
                       ('\\\\\\t ', '\\\t '),
                       ('\\tx', '\tx'),
                       ('\\\\tx', '\\tx'),
                       ('\\\\\\tx', '\\\tx'),
                       ('\\t x', '\t x'),
                       ('\\\\t x', '\\t x'),
                       ('\\\\\\t x', '\\\t x') ]:
         assert_equals(unescape(inp), exp, inp)
Exemplo n.º 4
0
 def test_cr(self):
     for inp, exp in [ ('\\r', '\r'),
                       ('\\\\r', '\\r'),
                       ('\\\\\\r', '\\\r'),
                       ('\\r ', '\r '),
                       ('\\\\r ', '\\r '),
                       ('\\\\\\r ', '\\\r '),
                       ('\\rx', '\rx'),
                       ('\\\\rx', '\\rx'),
                       ('\\\\\\rx', '\\\rx'),
                       ('\\r x', '\r x'),
                       ('\\\\r x', '\\r x'),
                       ('\\\\\\r x', '\\\r x') ]:
         assert_equals(unescape(inp), exp, inp)
Exemplo n.º 5
0
 def test_lf(self):
     for inp, exp in [ ('\\n', '\n'),
                       ('\\\\n', '\\n'),
                       ('\\\\\\n', '\\\n'),
                       ('\\n ', '\n'),
                       ('\\\\n ', '\\n '),
                       ('\\\\\\n ', '\\\n'),
                       ('\\nx', '\nx'),
                       ('\\\\nx', '\\nx'),
                       ('\\\\\\nx', '\\\nx'),
                       ('\\n x', '\nx'),
                       ('\\\\n x', '\\n x'),
                       ('\\\\\\n x', '\\\nx') ]:
         assert_equals(unescape(inp), exp, "'%s'" % inp)
Exemplo n.º 6
0
def assert_unescape(inp, exp):
    assert_equals(unescape(inp), exp, repr(inp))
Exemplo n.º 7
0
 def test_no_unescape(self):
     for inp in [ 'no escapes', '' ]:
         assert_equals(unescape(inp), inp)