OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """ | 3 """ |
4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 | 8 |
9 A wrapper around the standard Python unittest library, adding features we need | 9 A wrapper around the standard Python unittest library, adding features we need |
10 for various unittests within this directory. | 10 for various unittests within this directory. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 # to be validated. | 42 # to be validated. |
43 # 2. So put that validation within tearDown(), which will be called after | 43 # 2. So put that validation within tearDown(), which will be called after |
44 # every test case! | 44 # every test case! |
45 # | 45 # |
46 # I have confirmed that the test really does fail if this assert is | 46 # I have confirmed that the test really does fail if this assert is |
47 # triggered. | 47 # triggered. |
48 # | 48 # |
49 # Ravi notes: if somebody later comes along and adds cleanup code below | 49 # Ravi notes: if somebody later comes along and adds cleanup code below |
50 # this assert, then if tests fail, the artifacts will not be cleaned up. | 50 # this assert, then if tests fail, the artifacts will not be cleaned up. |
51 assert (not different_files), \ | 51 assert (not different_files), \ |
52 ('found differing files between actual dir %s and expected dir %s: %s' % | 52 ('found differing files:\n' + |
53 (self._output_dir_actual, self._output_dir_expected, different_files)) | 53 '\n'.join(['tkdiff %s %s &' % ( |
| 54 os.path.join(self._output_dir_actual, basename), |
| 55 os.path.join(self._output_dir_expected, basename)) |
| 56 for basename in different_files])) |
54 | 57 |
55 def shortDescription(self): | 58 def shortDescription(self): |
56 """Tell unittest framework to not print docstrings for test cases.""" | 59 """Tell unittest framework to not print docstrings for test cases.""" |
57 return None | 60 return None |
58 | 61 |
59 | 62 |
60 def create_empty_dir(path): | 63 def create_empty_dir(path): |
61 """Create an empty directory at the given path.""" | 64 """Create an empty directory at the given path.""" |
62 if os.path.isdir(path): | 65 if os.path.isdir(path): |
63 shutil.rmtree(path) | 66 shutil.rmtree(path) |
(...skipping 27 matching lines...) Expand all Loading... |
91 for common_dir in dircmp.common_dirs: | 94 for common_dir in dircmp.common_dirs: |
92 differing_files.extend(find_different_files( | 95 differing_files.extend(find_different_files( |
93 os.path.join(dir1, common_dir), os.path.join(dir2, common_dir))) | 96 os.path.join(dir1, common_dir), os.path.join(dir2, common_dir))) |
94 return differing_files | 97 return differing_files |
95 | 98 |
96 | 99 |
97 def main(test_case_class): | 100 def main(test_case_class): |
98 """Run the unit tests within the given class.""" | 101 """Run the unit tests within the given class.""" |
99 suite = unittest.TestLoader().loadTestsFromTestCase(test_case_class) | 102 suite = unittest.TestLoader().loadTestsFromTestCase(test_case_class) |
100 results = unittest.TextTestRunner(verbosity=2).run(suite) | 103 results = unittest.TextTestRunner(verbosity=2).run(suite) |
OLD | NEW |