@@ -65,7 +65,7 @@ async def test_compile_cpp_success():
6565 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
6666
6767 # 写入源代码
68- with open (source_path , "w" ) as f :
68+ with open (source_path , "w" , encoding = "utf-8" ) as f :
6969 f .write (HELLO_WORLD_CODE )
7070
7171 # 编译
@@ -84,7 +84,7 @@ async def test_compile_cpp_syntax_error():
8484 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
8585
8686 # 写入错误代码
87- with open (source_path , "w" ) as f :
87+ with open (source_path , "w" , encoding = "utf-8" ) as f :
8888 f .write ("invalid c++ code {{{" )
8989
9090 # 编译
@@ -103,7 +103,7 @@ async def test_compile_cpp_timeout():
103103 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
104104
105105 # 写入源代码
106- with open (source_path , "w" ) as f :
106+ with open (source_path , "w" , encoding = "utf-8" ) as f :
107107 f .write (HELLO_WORLD_CODE )
108108
109109 # 编译(设置极短超时)
@@ -135,7 +135,7 @@ async def test_run_binary_success():
135135 source_path = os .path .join (tmpdir , "test.cpp" )
136136 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
137137
138- with open (source_path , "w" ) as f :
138+ with open (source_path , "w" , encoding = "utf-8" ) as f :
139139 f .write (HELLO_WORLD_CODE )
140140
141141 compile_result = await compile_cpp (source_path , binary_path )
@@ -157,7 +157,7 @@ async def test_run_binary_timeout():
157157 source_path = os .path .join (tmpdir , "test.cpp" )
158158 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
159159
160- with open (source_path , "w" ) as f :
160+ with open (source_path , "w" , encoding = "utf-8" ) as f :
161161 f .write (INFINITE_LOOP_CODE )
162162
163163 compile_result = await compile_cpp (source_path , binary_path )
@@ -191,7 +191,7 @@ async def test_run_binary_with_stdin():
191191 source_path = os .path .join (tmpdir , "test.cpp" )
192192 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
193193
194- with open (source_path , "w" ) as f :
194+ with open (source_path , "w" , encoding = "utf-8" ) as f :
195195 f .write (stdin_code )
196196
197197 compile_result = await compile_cpp (source_path , binary_path )
@@ -212,7 +212,7 @@ async def test_run_binary_with_args():
212212 source_path = os .path .join (tmpdir , "test.cpp" )
213213 binary_path = os .path .join (tmpdir , "test" + (".exe" if os .name == "nt" else "" ))
214214
215- with open (source_path , "w" ) as f :
215+ with open (source_path , "w" , encoding = "utf-8" ) as f :
216216 f .write (ARGS_CODE )
217217
218218 compile_result = await compile_cpp (source_path , binary_path )
@@ -243,7 +243,7 @@ async def test_compile_all_success():
243243 sources = []
244244 for i in range (3 ):
245245 source_path = os .path .join (tmpdir , f"test{ i } .cpp" )
246- with open (source_path , "w" ) as f :
246+ with open (source_path , "w" , encoding = "utf-8" ) as f :
247247 f .write (f"""
248248#include <iostream>
249249
0 commit comments