1717from .logger import Logger
1818from .result import TestResult , State
1919from .results import TestResults
20- from .runtests import RunTests , JsonFileType , JSON_FILE_USE_FILENAME
20+ from .runtests import RunTests , JsonFileType
2121from .single import PROGRESS_MIN_TIME
2222from .utils import (
23- StrPath , StrJSON , TestName , MS_WINDOWS ,
23+ StrPath , StrJSON , TestName , MS_WINDOWS , TMP_PREFIX ,
2424 format_duration , print_warning , count , plural )
2525from .worker import create_worker_process , USE_PROCESS_GROUP
2626
@@ -228,9 +228,14 @@ def _runtest(self, test_name: TestName) -> MultiprocessResult:
228228 err_msg = None
229229
230230 stdout_file = tempfile .TemporaryFile ('w+' , encoding = encoding )
231- if JSON_FILE_USE_FILENAME :
232- json_tmpfile = tempfile .NamedTemporaryFile ('w+' , encoding = 'utf8' )
233- print ("main process: create NamedTemporaryFile" )
231+
232+ json_file_use_filename = self .runtests .json_file_use_filename ()
233+ print ("main process: json_file_use_filename?" , json_file_use_filename )
234+ if json_file_use_filename :
235+ prefix = TMP_PREFIX + 'json_'
236+ json_tmpfile = tempfile .NamedTemporaryFile ('w+' , encoding = 'utf8' ,
237+ prefix = prefix )
238+ print ("main process: create NamedTemporaryFile" , json_tmpfile .name )
234239 else :
235240 json_tmpfile = tempfile .TemporaryFile ('w+' , encoding = 'utf8' )
236241 print ("main process: create TemporaryFile" )
@@ -239,14 +244,14 @@ def _runtest(self, test_name: TestName) -> MultiprocessResult:
239244 # non-blocking pipes on Emscripten with NodeJS.
240245 with (stdout_file , json_tmpfile ):
241246 stdout_fd = stdout_file .fileno ()
242- if JSON_FILE_USE_FILENAME :
247+ if json_file_use_filename :
243248 json_file = json_tmpfile .name
244249 else :
245250 json_file = json_tmpfile .fileno ()
246251 if MS_WINDOWS :
247252 json_file = msvcrt .get_osfhandle (json_file )
248- print ("main process json_type file :" , type (json_file ))
249- print ("main process json_type :" , json_file )
253+ print ("main process json_file type :" , type (json_file ))
254+ print ("main process json_file :" , json_file )
250255
251256 kwargs = {}
252257 if match_tests :
0 commit comments