OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 '''Unit tests for grit.format.check_dups''' |
| 7 |
| 8 import os |
| 9 import sys |
| 10 if __name__ == '__main__': |
| 11 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) |
| 12 |
| 13 import tempfile |
| 14 import unittest |
| 15 |
| 16 from grit.format import check_dups |
| 17 from grit.format import data_pack |
| 18 |
| 19 class CheckDupsUnittest(unittest.TestCase): |
| 20 def testDuplicateResource(self): |
| 21 first = {1: '', 4: 'this is id 4', 6: 'this is id 6', 10: ''} |
| 22 first_pak = data_pack.WriteDataPackToString(first, data_pack.UTF8) |
| 23 first_file = tempfile.NamedTemporaryFile() |
| 24 first_file.write(first_pak) |
| 25 first_file.flush() |
| 26 |
| 27 second = {2: 'resource 2', 3: 'resource 3', 4: 'resource 4'} |
| 28 second_pak = data_pack.WriteDataPackToString(second, data_pack.UTF8) |
| 29 second_file = tempfile.NamedTemporaryFile() |
| 30 second_file.write(second_pak) |
| 31 second_file.flush() |
| 32 |
| 33 exception_thrown = False |
| 34 try: |
| 35 check_dups.CheckDupResource([first_file.name, second_file.name]) |
| 36 except check_dups.ResourceDuplicateException: |
| 37 exception_thrown = True |
| 38 self.failUnless(exception_thrown) |
| 39 |
| 40 |
| 41 if __name__ == '__main__': |
| 42 unittest.main() |
OLD | NEW |