Index: grit/format/check_dups_unittest.py |
diff --git a/grit/format/check_dups_unittest.py b/grit/format/check_dups_unittest.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..762edfa7b015481a96eafcad3449104d44d9aab9 |
--- /dev/null |
+++ b/grit/format/check_dups_unittest.py |
@@ -0,0 +1,42 @@ |
+#!/usr/bin/env python |
+# Copyright 2015 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+'''Unit tests for grit.format.check_dups''' |
+ |
+import os |
+import sys |
+if __name__ == '__main__': |
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) |
+ |
+import tempfile |
+import unittest |
+ |
+from grit.format import check_dups |
+from grit.format import data_pack |
+ |
+class CheckDupsUnittest(unittest.TestCase): |
+ def testDuplicateResource(self): |
+ first = {1: '', 4: 'this is id 4', 6: 'this is id 6', 10: ''} |
+ first_pak = data_pack.WriteDataPackToString(first, data_pack.UTF8) |
+ first_file = tempfile.NamedTemporaryFile() |
+ first_file.write(first_pak) |
+ first_file.flush() |
+ |
+ second = {2: 'resource 2', 3: 'resource 3', 4: 'resource 4'} |
+ second_pak = data_pack.WriteDataPackToString(second, data_pack.UTF8) |
+ second_file = tempfile.NamedTemporaryFile() |
+ second_file.write(second_pak) |
+ second_file.flush() |
+ |
+ exception_thrown = False |
+ try: |
+ check_dups.CheckDupResource([first_file.name, second_file.name]) |
+ except check_dups.ResourceDuplicateException: |
+ exception_thrown = True |
+ self.failUnless(exception_thrown) |
+ |
+ |
+if __name__ == '__main__': |
+ unittest.main() |