Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Unified Diff: grit/format/check_dups_unittest.py

Issue 1056993003: check_dups: Add a script to check for the same resource in multiple pak files. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: . Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/format/check_dups.py ('k') | grit/test_suite_all.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « grit/format/check_dups.py ('k') | grit/test_suite_all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698