Пример #1
0
 def test_escape(self):
     for inp, exp in [('nothing to escape', 'nothing to escape'),
                      ('still nothing $ @', 'still nothing $ @' ),
                      ('1 backslash to 2: \\', '1 backslash to 2: \\\\'),
                      ('3 bs to 6: \\\\\\', '3 bs to 6: \\\\\\\\\\\\'),
                      ('\\' * 1000, '\\' * 2000 ),
                      ('${notvar}', '\\${notvar}'),
                      ('@{notvar}', '\\@{notvar}'),
                      ('${nv} ${nv} @{nv}', '\\${nv} \\${nv} \\@{nv}'),
                      ('\\${already esc}', '\\\\\\${already esc}'),
                      ('\\${ae} \\\\@{ae} \\\\\\@{ae}',
                       '\\\\\\${ae} \\\\\\\\\\@{ae} \\\\\\\\\\\\\\@{ae}'),
                      ('%{reserved}', '\\%{reserved}'),
                      ('&{reserved}', '\\&{reserved}'),
                      ('*{reserved}', '\\*{reserved}'),
                      ('x{notreserved}', 'x{notreserved}'),
                      ('named=arg', 'named\\=arg')]:
         assert_equals(escape(inp), exp, inp)
Пример #2
0
 def test_escape_control_words(self):
     for inp in ['ELSE', 'ELSE IF', 'AND']:
         assert_equals(escape(inp), '\\' + inp)
         assert_equals(escape(inp.lower()), inp.lower())
         assert_equals(escape('other' + inp), 'other' + inp)
         assert_equals(escape(inp + ' '), inp + ' ')