def test_dir_exist(self): lzw.Compressor( 'tests/arch.lzw', lzw.get_files_with_path_and_name(['tests/files/0.txt'])).compress() lzw.Decompressor('tests/arch.lzw', 'tests', False, False, False, False).decompress() self.assertTrue(os.path.exists('tests/0.txt')) os.remove('tests/0.txt')
def test_file_damaged_with_a(self): lzw.Compressor( 'tests/arch.lzw', lzw.get_files_with_path_and_name(['tests/files/0.txt'])).compress() with open('tests/arch.lzw', 'rb+') as f: f.seek(-10, 2) f.write(b'\x00') with self.assertWarns(UserWarning): lzw.Decompressor('tests/arch.lzw', 'tests', False, False, True, False).decompress() self.assertFalse(os.path.exists('tests/0.txt'))
def test_restore(self): lzw.Compressor( 'tests/arch.lzw', lzw.get_files_with_path_and_name(['tests/files/0.txt'])).compress() stat = os.stat('tests/files/0.txt') c_md = [stat.st_mode, stat.st_atime, stat.st_mtime] lzw.Decompressor('tests/arch.lzw', 'tests', True, False, False, True).decompress() stat = os.stat('tests/0.txt') r_md = [stat.st_mode, stat.st_atime, stat.st_mtime] self.assertListEqual(c_md, r_md) os.remove('tests/0.txt')