Allen Li | b41527d | 2017-06-22 17:28:00 -0700 | [diff] [blame] | 1 | #!/usr/bin/python2.7 |
| 2 | # |
| 3 | # Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | import unittest |
| 8 | |
| 9 | import common |
| 10 | from autotest_lib.utils import gslib |
| 11 | |
| 12 | |
| 13 | class EscapeTestCase(unittest.TestCase): |
| 14 | """Tests for basic KeyvalLabel functions.""" |
| 15 | |
| 16 | def test_escape_printable(self): |
| 17 | """Test escaping printable characters.""" |
| 18 | got = gslib.escape('foo[]*?#') |
| 19 | self.assertEqual(got, 'foo%5b%5d%2a%3f%23') |
| 20 | |
| 21 | def test_escape_control(self): |
| 22 | """Test escaping control characters by hex.""" |
| 23 | got = gslib.escape('foo\x88') |
| 24 | self.assertEqual(got, 'foo%88') |
| 25 | |
| 26 | |
| 27 | if __name__ == '__main__': |
| 28 | unittest.main() |