| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 4 # Copyright (C) 2006-2016 Eyeo GmbH | 4 # Copyright (C) 2006-2016 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 ("foo_bar", True), | 29 ("foo_bar", True), |
| 30 ("1234.txt", True), | 30 ("1234.txt", True), |
| 31 ("xYz.DAT", True), | 31 ("xYz.DAT", True), |
| 32 ("foo/bar.txt", False), | 32 ("foo/bar.txt", False), |
| 33 ("foo/bar+bas-xyz.txt", False), | 33 ("foo/bar+bas-xyz.txt", False), |
| 34 (u"foo\u1234-bar\u4321", False), | 34 (u"foo\u1234-bar\u4321", False), |
| 35 ("foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo
obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob
arfoobarfoobar", u"foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarf
oobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo
barfoobar\u2026") | 35 ("foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo
obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob
arfoobarfoobar", u"foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarf
oobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo
barfoobar\u2026") |
| 36 ] | 36 ] |
| 37 for name, expect_identical in tests: | 37 for name, expect_identical in tests: |
| 38 path = common.filename_encode(name) | 38 path = common.filename_encode(name) |
| 39 if expect_identical == True: | 39 if expect_identical is True: |
| 40 self.assertEqual(path, name, "Encoding '%s' shouldn't change str
ing" % name) | 40 self.assertEqual(path, name, "Encoding '%s' shouldn't change str
ing" % name) |
| 41 else: | 41 else: |
| 42 self.assertTrue(re.match(r"^[\w\.\-]*$", path), "Encoding '%s' s
hould replace all special characters" % name) | 42 self.assertTrue(re.match(r"^[\w\.\-]*$", path), "Encoding '%s' s
hould replace all special characters" % name) |
| 43 | 43 |
| 44 if isinstance(expect_identical, basestring): | 44 if isinstance(expect_identical, basestring): |
| 45 self.assertEqual(common.filename_decode(path), expect_identical,
"Encoding and decoding '%s' should produce a truncated string as result" % name
) | 45 self.assertEqual(common.filename_decode(path), expect_identical,
"Encoding and decoding '%s' should produce a truncated string as result" % name
) |
| 46 else: | 46 else: |
| 47 self.assertEqual(common.filename_decode(path), name, "Encoding a
nd decoding '%s' should produce the original string" % name) | 47 self.assertEqual(common.filename_decode(path), name, "Encoding a
nd decoding '%s' should produce the original string" % name) |
| 48 | 48 |
| 49 if __name__ == '__main__': | 49 if __name__ == '__main__': |
| 50 unittest.main() | 50 unittest.main() |
| OLD | NEW |