@@ -914,7 +914,7 @@ def test_log_error_standard_log_sink(self, mock_stdout):
914914
915915 def test_log_error_framed_log_sink (self ):
916916 with NamedTemporaryFile () as temp_file :
917- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
917+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
918918 err_to_log = bootstrap .make_error ("Error message" , "ErrorType" , None )
919919 bootstrap .log_error (err_to_log , log_sink )
920920
@@ -949,7 +949,7 @@ def test_log_error_indentation_standard_log_sink(self, mock_stdout):
949949
950950 def test_log_error_indentation_framed_log_sink (self ):
951951 with NamedTemporaryFile () as temp_file :
952- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
952+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
953953 err_to_log = bootstrap .make_error (
954954 "Error message" , "ErrorType" , [" line1 " , " line2 " , " " ]
955955 )
@@ -984,7 +984,7 @@ def test_log_error_empty_stacktrace_line_standard_log_sink(self, mock_stdout):
984984
985985 def test_log_error_empty_stacktrace_line_framed_log_sink (self ):
986986 with NamedTemporaryFile () as temp_file :
987- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as log_sink :
987+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as log_sink :
988988 err_to_log = bootstrap .make_error (
989989 "Error message" , "ErrorType" , ["line1" , "" , "line2" ]
990990 )
@@ -1070,19 +1070,19 @@ def test_create_unbuffered_log_sinks(self, mock_stdout):
10701070 self .assertEqual (mock_stdout .getvalue (), "log" )
10711071
10721072 def test_create_framed_telemetry_log_sinks (self ):
1073- fd = "test_fd"
1074- os .environ ["_LAMBDA_TELEMETRY_LOG_FD" ] = fd
1073+ fd = 3
1074+ os .environ ["_LAMBDA_TELEMETRY_LOG_FD" ] = "3"
10751075
10761076 actual = bootstrap .create_log_sink ()
10771077
10781078 self .assertIsInstance (actual , bootstrap .FramedTelemetryLogSink )
1079- self .assertEqual (actual .filename , "/proc/self/fd/" + fd )
1079+ self .assertEqual (actual .fd , fd )
10801080 self .assertFalse ("_LAMBDA_TELEMETRY_LOG_FD" in os .environ )
10811081
10821082 def test_single_frame (self ):
10831083 with NamedTemporaryFile () as temp_file :
10841084 message = "hello world\n something on a new line!\n "
1085- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as ls :
1085+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as ls :
10861086 ls .log (message )
10871087 with open (temp_file .name , "rb" ) as f :
10881088 content = f .read ()
@@ -1101,7 +1101,7 @@ def test_multiple_frame(self):
11011101 first_message = "hello world\n something on a new line!"
11021102 second_message = "hello again\n here's another message\n "
11031103
1104- with bootstrap .FramedTelemetryLogSink (temp_file .name ) as ls :
1104+ with bootstrap .FramedTelemetryLogSink (os . open ( temp_file .name , os . O_CREAT | os . O_RDWR ) ) as ls :
11051105 ls .log (first_message )
11061106 ls .log (second_message )
11071107
0 commit comments