create a file with the same size and mtime but different content.
(template_path, new_path)
| 10 | |
| 11 | |
| 12 | def _create_file_shallow_equal(template_path, new_path): |
| 13 | """create a file with the same size and mtime but different content.""" |
| 14 | shutil.copy2(template_path, new_path) |
| 15 | with open(new_path, 'r+b') as f: |
| 16 | next_char = bytearray(f.read(1)) |
| 17 | next_char[0] = (next_char[0] + 1) % 256 |
| 18 | f.seek(0) |
| 19 | f.write(next_char) |
| 20 | shutil.copystat(template_path, new_path) |
| 21 | assert os.stat(new_path).st_size == os.stat(template_path).st_size |
| 22 | assert os.stat(new_path).st_mtime == os.stat(template_path).st_mtime |
| 23 | |
| 24 | class FileCompareTestCase(unittest.TestCase): |
| 25 | def setUp(self): |