| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 '''Unit test that checks some of util functions. | 6 '''Unit test that checks some of util functions. |
| 7 ''' | 7 ''' |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 self.failUnless(util.CanonicalLanguage('pt-br') == 'pt-BR') | 48 self.failUnless(util.CanonicalLanguage('pt-br') == 'pt-BR') |
| 49 self.failUnless(util.CanonicalLanguage('pt-BR') == 'pt-BR') | 49 self.failUnless(util.CanonicalLanguage('pt-BR') == 'pt-BR') |
| 50 self.failUnless(util.CanonicalLanguage('pt/br') == 'pt-BR') | 50 self.failUnless(util.CanonicalLanguage('pt/br') == 'pt-BR') |
| 51 self.failUnless(util.CanonicalLanguage('pt/BR') == 'pt-BR') | 51 self.failUnless(util.CanonicalLanguage('pt/BR') == 'pt-BR') |
| 52 self.failUnless(util.CanonicalLanguage('no_no_bokmal') == 'no-NO-BOKMAL') | 52 self.failUnless(util.CanonicalLanguage('no_no_bokmal') == 'no-NO-BOKMAL') |
| 53 | 53 |
| 54 def testUnescapeHtml(self): | 54 def testUnescapeHtml(self): |
| 55 self.failUnless(util.UnescapeHtml('ϲ') == unichr(1010)) | 55 self.failUnless(util.UnescapeHtml('ϲ') == unichr(1010)) |
| 56 self.failUnless(util.UnescapeHtml('ꯍ') == unichr(43981)) | 56 self.failUnless(util.UnescapeHtml('ꯍ') == unichr(43981)) |
| 57 | 57 |
| 58 def testRelativePath(self): |
| 59 """ Verify that MakeRelativePath works in some tricky cases.""" |
| 60 |
| 61 def TestRelativePathCombinations(base_path, other_path, expected_result): |
| 62 """ Verify that the relative path function works for |
| 63 the given paths regardless of whether or not they end with |
| 64 a trailing slash.""" |
| 65 for path1 in [base_path, base_path + os.path.sep]: |
| 66 for path2 in [other_path, other_path + os.path.sep]: |
| 67 result = util.MakeRelativePath(path1, path2) |
| 68 self.failUnless(result == expected_result) |
| 69 |
| 70 # set-up variables |
| 71 root_dir = 'c:%sa' % os.path.sep |
| 72 result1 = '..%sabc' % os.path.sep |
| 73 path1 = root_dir + 'bc' |
| 74 result2 = 'bc' |
| 75 path2 = '%s%s%s' % (root_dir, os.path.sep, result2) |
| 76 # run the tests |
| 77 TestRelativePathCombinations(root_dir, path1, result1) |
| 78 TestRelativePathCombinations(root_dir, path2, result2) |
| 79 |
| 58 class TestBaseClassToLoad(object): | 80 class TestBaseClassToLoad(object): |
| 59 pass | 81 pass |
| 60 | 82 |
| 61 class TestClassToLoad(TestBaseClassToLoad): | 83 class TestClassToLoad(TestBaseClassToLoad): |
| 62 pass | 84 pass |
| 63 | 85 |
| 64 class TestClassNoBase(object): | 86 class TestClassNoBase(object): |
| 65 pass | 87 pass |
| 66 | 88 |
| 67 | 89 |
| 68 if __name__ == '__main__': | 90 if __name__ == '__main__': |
| 69 unittest.main() | 91 unittest.main() |
| 70 | 92 |
| OLD | NEW |