def test_add_updated_ctime(self): # Adding an existing file with a ctime newer than that of the # checksums file causes its checksum to be updated. path = os.path.join(self.temp_dir, "entry") with mkfile(path) as entry: print("ctime", end="", file=entry) checksum_file = ChecksumFile(self.config, self.temp_dir, "MD5SUMS", hashlib.md5, sign=False) checksum_file.entries["entry"] = "" checksum_file.changed = True checksum_file.write() # We can simulate a ctime change by rewinding the mtime of both # entry and the checksums file. self.rewind_mtime(checksum_file.path) self.rewind_mtime(path) checksum_file.add("entry") self.assertEqual( hashlib.md5(b"ctime").hexdigest(), checksum_file.entries["entry"])