@@ -459,11 +459,15 @@ def test_garbage_private_dir_worker(tmp_path):
459459 _output = outgoing_buffer ,
460460 private_data_dir = worker_dir ,
461461 )
462- sent = outgoing_buffer .getvalue ()
463- assert b'"status": "error"' in sent
462+ outgoing_buffer .seek (0 )
463+ sent = outgoing_buffer .readline ()
464+ data = json .loads (sent )
465+ assert data ['status' ] == 'error'
466+ assert data ['job_explanation' ] == 'Failed to extract private data directory on worker.'
467+ assert data ['result_traceback' ]
464468
465469
466- def test_unparsable_private_dir_worker (tmp_path ):
470+ def test_unparsable_line_worker (tmp_path ):
467471 worker_dir = tmp_path / 'for_worker'
468472 worker_dir .mkdir ()
469473 incoming_buffer = io .BytesIO (b'' )
@@ -476,18 +480,27 @@ def test_unparsable_private_dir_worker(tmp_path):
476480 _output = outgoing_buffer ,
477481 private_data_dir = worker_dir ,
478482 )
479- sent = outgoing_buffer .getvalue ()
480- assert b'"status": "error"' in sent
483+ outgoing_buffer .seek (0 )
484+ sent = outgoing_buffer .readline ()
485+ data = json .loads (sent )
486+ assert data ['status' ] == 'error'
487+ assert data ['job_explanation' ] == 'Failed to JSON parse a line from transmit stream.'
481488
482489
483- def test_unparsable_private_dir_processor (tmp_path ):
490+ def test_unparsable_really_big_line_processor (tmp_path ):
484491 process_dir = tmp_path / 'for_process'
485492 process_dir .mkdir ()
486- incoming_buffer = io .BytesIO (b'' )
493+ incoming_buffer = io .BytesIO (bytes (f'not-json-data with extra garbage:{ "f" * 10000 } ' , encoding = 'utf-8' ))
494+
495+ def status_receiver (status_data , runner_config ):
496+ assert status_data ['status' ] == 'error'
497+ assert 'Failed to JSON parse a line from worker stream.' in status_data ['job_explanation' ]
498+ assert 'not-json-data with extra garbage:ffffffffff' in status_data ['job_explanation' ]
499+ assert len (status_data ['job_explanation' ]) < 2000
487500
488- processor = run (
501+ run (
489502 streamer = 'process' ,
490503 _input = incoming_buffer ,
491504 private_data_dir = process_dir ,
505+ status_handler = status_receiver
492506 )
493- assert processor .status == 'error'
0 commit comments