提交 667be49c 编写于 作者: J Jan Zerebecki

Fix byte vs string file io for python 3

Reference: https://github.com/avocado-framework/avocado/issues/2024Signed-off-by: NJan Zerebecki <jan.foss@zerebecki.de>
上级 c0156e43
......@@ -27,7 +27,8 @@ class ArchiveTest(unittest.TestCase):
compressdir = self.compressdir
str_length = self.sys_random.randint(30, 50)
fd, filename = tempfile.mkstemp(dir=compressdir, text=True)
os.write(fd, data_factory.generate_random_string(str_length))
with os.fdopen(fd, 'w') as f:
f.write(data_factory.generate_random_string(str_length))
relative_path = filename.replace(self.compressdir, '')
hash_map_1[relative_path] = crypto.hash_file(filename)
......@@ -47,7 +48,8 @@ class ArchiveTest(unittest.TestCase):
def compress_and_check_file(self, extension):
str_length = self.sys_random.randint(30, 50)
fd, filename = tempfile.mkstemp(dir=self.basedir, text=True)
os.write(fd, data_factory.generate_random_string(str_length))
with os.fdopen(fd, 'w') as f:
f.write(data_factory.generate_random_string(str_length))
original_hash = crypto.hash_file(filename)
dstfile = filename + extension
archive_filename = os.path.join(self.basedir, dstfile)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册