@@ -465,33 +465,28 @@ def test_ffpuppet_20(tmp_path):
465465assert ffp ._logs .path is not None
466466test_logs = [ffp ._logs .path / f"{ ffp ._logs .PREFIX_SAN } .{ i } " for i in range (4 )]
467467# ignore benign ASan warning
468- with test_logs [0 ].open ("w" )as log_fp :
469- log_fp .write ("==123==WARNING: Symbolizer buffer too small" )
468+ test_logs [0 ].write_text ("==123==WARNING: Symbolizer buffer too small" )
470469assert ffp .is_healthy ()
471470# small log with nothing interesting
472- with test_logs [1 ].open ("w" )as log_fp :
473- log_fp .write ("SHORT LOG\n " )
474- log_fp .write ("filler line" )
475- # crash on another thread
476- with test_logs [2 ].open ("w" )as log_fp :
477- log_fp .write ("GOOD LOG\n " )
478- log_fp .write (
479- "==70811==ERROR: AddressSanitizer:"
480- " SEGV on unknown address 0x00000BADF00D"
481- " (pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T0)\n "
482- )# must be 2nd line
483- for _ in range (4 ):# pad out to 6 lines
484- log_fp .write ("filler line\n " )
471+ test_logs [1 ].write_text ("SHORT LOG\n filler line" )
472+ # crash on another thread (error log must start on 2nd line)
473+ test_logs [2 ].write_text (
474+ "GOOD LOG\n "
475+ "==70811==ERROR: AddressSanitizer: SEGV on unknown address 0x00000BADF00D "
476+ "(pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T0)\n "
477+ # pad out to 6 lines
478+ "filler line\n filler line\n filler line\n "
479+ "filler line\n filler line\n filler line\n "
480+ )
485481# child log that should be ignored (created when parent crashes)
486- with test_logs [3 ].open ("w" )as log_fp :
487- log_fp .write ("BAD LOG\n " )
488- log_fp .write (
489- "==70811==ERROR: AddressSanitizer:"
490- " SEGV on unknown address 0x000000000000"
491- " (pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T2)\n "
492- )# must be 2nd line
493- for _ in range (4 ):# pad out to 6 lines
494- log_fp .write ("filler line\n " )
482+ test_logs [3 ].write_text (
483+ "BAD LOG\n "
484+ "==70811==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 "
485+ "(pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T2)\n "
486+ # pad out to 6 lines
487+ "filler line\n filler line\n filler line\n "
488+ "filler line\n filler line\n filler line\n "
489+ )
495490assert not ffp .is_healthy ()
496491assert ffp .is_running ()
497492# close fake browser process before calling close to avoid hang
@@ -504,15 +499,15 @@ def test_ffpuppet_20(tmp_path):
504499assert len (logfiles )== 6
505500for logfile in logfiles :
506501if "log_ffp_asan_" not in str (logfile ):
507- assert logfile .name in ( "log_stderr.txt" ,"log_stdout.txt" )
502+ assert logfile .name in { "log_stderr.txt" ,"log_stdout.txt" }
508503continue
509504with logfile .open ("r" )as log_fp :
510- assert log_fp .readline ()in (
505+ assert log_fp .readline ()in {
511506"BAD LOG\n " ,
512507"GOOD LOG\n " ,
513508"SHORT LOG\n " ,
514509"==123==WARNING: Symbolizer buffer too small" ,
515- )
510+ }
516511assert not any (f .is_file ()for f in test_logs )
517512
518513
@@ -856,13 +851,12 @@ def test_ffpuppet_28():
856851with FFPuppet ()as ffp :
857852ffp .launch (TESTFF_BIN )
858853assert ffp ._logs .path is not None
859- san_log = f" { ffp ._logs .path / ffp ._logs .PREFIX_SAN } .1"
854+ san_log = ffp ._logs .path / f" { ffp ._logs .PREFIX_SAN } .1"
860855assert not ffp ._logs .watching
861856# ignore benign ASan warning
862- with open (san_log ,"w" )as log_fp :
863- log_fp .write ("==123==WARNING: Symbolizer buffer too small" )
857+ san_log .write_text ("==123==WARNING: Symbolizer buffer too small" )
864858assert ffp .is_healthy ()
865- assert san_log in ffp ._logs .watching
859+ assert str ( san_log ) in ffp ._logs .watching
866860ffp .close ()
867861assert ffp .reason == Reason .CLOSED
868862