提交 d60b0003 编写于 作者: P Paolo Bonzini

specify text mode for NamedTemporaryFile

Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 418bf92a
...@@ -201,14 +201,16 @@ class Diff(CLICmd): ...@@ -201,14 +201,16 @@ class Diff(CLICmd):
if getattr(args, 'create_reports', False): if getattr(args, 'create_reports', False):
self.std_diff_output = False self.std_diff_output = False
prefix = 'avocado_diff_%s_' % job1_id[:7] prefix = 'avocado_diff_%s_' % job1_id[:7]
tmp_file1 = tempfile.NamedTemporaryFile(prefix=prefix, tmp_file1 = tempfile.NamedTemporaryFile(mode='w',
prefix=prefix,
suffix='.txt', suffix='.txt',
delete=False) delete=False)
tmp_file1.writelines(job1_results) tmp_file1.writelines(job1_results)
tmp_file1.close() tmp_file1.close()
prefix = 'avocado_diff_%s_' % job2_id[:7] prefix = 'avocado_diff_%s_' % job2_id[:7]
tmp_file2 = tempfile.NamedTemporaryFile(prefix=prefix, tmp_file2 = tempfile.NamedTemporaryFile(mode='w',
prefix=prefix,
suffix='.txt', suffix='.txt',
delete=False) delete=False)
tmp_file2.writelines(job2_results) tmp_file2.writelines(job2_results)
...@@ -220,7 +222,8 @@ class Diff(CLICmd): ...@@ -220,7 +222,8 @@ class Diff(CLICmd):
getattr(args, 'html', None) is None): getattr(args, 'html', None) is None):
prefix = 'avocado_diff_%s_%s_' % (job1_id[:7], job2_id[:7]) prefix = 'avocado_diff_%s_%s_' % (job1_id[:7], job2_id[:7])
tmp_file = tempfile.NamedTemporaryFile(prefix=prefix, tmp_file = tempfile.NamedTemporaryFile(mode='w',
prefix=prefix,
suffix='.html', suffix='.html',
delete=False) delete=False)
......
...@@ -28,7 +28,7 @@ class DataDirTest(unittest.TestCase): ...@@ -28,7 +28,7 @@ class DataDirTest(unittest.TestCase):
'test_dir = %(test_dir)s\n' 'test_dir = %(test_dir)s\n'
'data_dir = %(data_dir)s\n' 'data_dir = %(data_dir)s\n'
'logs_dir = %(logs_dir)s\n') % mapping 'logs_dir = %(logs_dir)s\n') % mapping
config_file = tempfile.NamedTemporaryFile(delete=False) config_file = tempfile.NamedTemporaryFile('w', delete=False)
config_file.write(temp_settings) config_file.write(temp_settings)
config_file.close() config_file.close()
return (mapping, config_file.name) return (mapping, config_file.name)
......
...@@ -19,7 +19,7 @@ home_path = ~ ...@@ -19,7 +19,7 @@ home_path = ~
class SettingsTest(unittest.TestCase): class SettingsTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.config_file = tempfile.NamedTemporaryFile(delete=False) self.config_file = tempfile.NamedTemporaryFile('w', delete=False)
self.config_file.write(example_1) self.config_file.write(example_1)
self.config_file.close() self.config_file.close()
self.settings = settings.Settings(self.config_file.name) self.settings = settings.Settings(self.config_file.name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册