OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright 2014 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 """ |
| 9 Common code for tests. |
| 10 """ |
| 11 import filecmp |
| 12 import os |
| 13 |
| 14 EXPECTATIONS_DIR = os.path.join(os.path.dirname(__file__), 'expectations') |
| 15 |
| 16 def compare_to_expectation(actual_name, expectation_name, assert_true, |
| 17 msg=None): |
| 18 """Check that a generated file matches its expectation in EXPECTATIONS_DIR. |
| 19 |
| 20 Assert that the generated file and expectation file are identical. |
| 21 |
| 22 Args: |
| 23 actual_name: Full path to the test file. |
| 24 expectation_name: Basename of the expectations file within which |
| 25 to compare. The file is expected to be in |
| 26 platform_tools/android/tests/expectations. |
| 27 assert_true: function for asserting a statement is True |
| 28 |
| 29 Args: |
| 30 condition: statement to check for True. |
| 31 msg: message to print if the files are not equal. |
| 32 |
| 33 msg: Message to pass to assert_true. |
| 34 """ |
| 35 full_expectations_path = os.path.join(EXPECTATIONS_DIR, expectation_name) |
| 36 assert_true(filecmp.cmp(actual_name, full_expectations_path), msg) |
OLD | NEW |