(test, actual, expected)
| 21 | |
| 22 | |
| 23 | def assert_file(test, actual, expected) -> None: |
| 24 | actual_filepath = os.path.join(fixture_dir, actual) |
| 25 | expected_filepath = os.path.join(expected_dir, expected) |
| 26 | |
| 27 | with open(expected_filepath) as in_file: |
| 28 | in_bytes = in_file.read() |
| 29 | in_bytes = in_bytes.strip() |
| 30 | expected_bytes = re.escape(in_bytes) |
| 31 | expected_bytes = expected_bytes.replace("\\*", ".*") |
| 32 | expected_re = re.compile(expected_bytes) |
| 33 | |
| 34 | with open(actual_filepath) as in_file: |
| 35 | actual_bytes = in_file.read() |
| 36 | actual_bytes = actual_bytes.strip() |
| 37 | |
| 38 | try: |
| 39 | test.assertRegex(actual_bytes, expected_re) |
| 40 | except Exception: |
| 41 | shutil.copyfile(actual_filepath, f"{expected_filepath}.actual") |
| 42 | raise |
| 43 | |
| 44 | |
| 45 | class TestGypUnix(unittest.TestCase): |
no test coverage detected