@@ -277,15 +277,21 @@ def __init__(self, message):
277277 xray_fault = json .loads (args [2 ])
278278 self .assertEqual (xray_fault ["working_directory" ], self .working_directory )
279279 self .assertEqual (len (xray_fault ["exceptions" ]), 1 )
280- self .assertEqual (xray_fault ["exceptions" ][0 ]["message" ], expected_response ["errorMessage" ])
281- self .assertEqual (xray_fault ["exceptions" ][0 ]["type" ], expected_response ["errorType" ])
280+ self .assertEqual (
281+ xray_fault ["exceptions" ][0 ]["message" ], expected_response ["errorMessage" ]
282+ )
283+ self .assertEqual (
284+ xray_fault ["exceptions" ][0 ]["type" ], expected_response ["errorType" ]
285+ )
282286 self .assertEqual (len (xray_fault ["exceptions" ][0 ]["stack" ]), 1 )
283287 self .assertEqual (
284288 xray_fault ["exceptions" ][0 ]["stack" ][0 ]["label" ], "raise_exception_handler"
285289 )
286290 self .assertIsInstance (xray_fault ["exceptions" ][0 ]["stack" ][0 ]["line" ], int )
287291 self .assertTrue (
288- xray_fault ["exceptions" ][0 ]["stack" ][0 ]["path" ].endswith (os .path .relpath (__file__ ))
292+ xray_fault ["exceptions" ][0 ]["stack" ][0 ]["path" ].endswith (
293+ os .path .relpath (__file__ )
294+ )
289295 )
290296 self .assertEqual (len (xray_fault ["paths" ]), 1 )
291297 self .assertTrue (xray_fault ["paths" ][0 ].endswith (os .path .relpath (__file__ )))
@@ -323,15 +329,21 @@ def __init__(self, message):
323329 xray_fault = json .loads (args [2 ])
324330 self .assertEqual (xray_fault ["working_directory" ], self .working_directory )
325331 self .assertEqual (len (xray_fault ["exceptions" ]), 1 )
326- self .assertEqual (xray_fault ["exceptions" ][0 ]["message" ], expected_response ["errorMessage" ])
327- self .assertEqual (xray_fault ["exceptions" ][0 ]["type" ], expected_response ["errorType" ])
332+ self .assertEqual (
333+ xray_fault ["exceptions" ][0 ]["message" ], expected_response ["errorMessage" ]
334+ )
335+ self .assertEqual (
336+ xray_fault ["exceptions" ][0 ]["type" ], expected_response ["errorType" ]
337+ )
328338 self .assertEqual (len (xray_fault ["exceptions" ][0 ]["stack" ]), 1 )
329339 self .assertEqual (
330340 xray_fault ["exceptions" ][0 ]["stack" ][0 ]["label" ], "raise_exception_handler"
331341 )
332342 self .assertIsInstance (xray_fault ["exceptions" ][0 ]["stack" ][0 ]["line" ], int )
333343 self .assertTrue (
334- xray_fault ["exceptions" ][0 ]["stack" ][0 ]["path" ].endswith (os .path .relpath (__file__ ))
344+ xray_fault ["exceptions" ][0 ]["stack" ][0 ]["path" ].endswith (
345+ os .path .relpath (__file__ )
346+ )
335347 )
336348 self .assertEqual (len (xray_fault ["paths" ]), 1 )
337349 self .assertTrue (xray_fault ["paths" ][0 ].endswith (os .path .relpath (__file__ )))
@@ -460,7 +472,9 @@ def raise_exception_handler(json_input, lambda_context):
460472 try :
461473 import invalid_module # noqa: F401
462474 except ImportError :
463- raise bootstrap .FaultException ("FaultExceptionType" , "Fault exception msg" , None )
475+ raise bootstrap .FaultException (
476+ "FaultExceptionType" , "Fault exception msg" , None
477+ )
464478
465479 bootstrap .handle_event_request (
466480 self .lambda_runtime ,
@@ -474,14 +488,14 @@ def raise_exception_handler(json_input, lambda_context):
474488 0 ,
475489 bootstrap .StandardLogSink (),
476490 )
477- error_logs = (
478- "[ERROR] FaultExceptionType: Fault exception msg\r Traceback (most recent call last):\n "
479- )
491+ error_logs = "[ERROR] FaultExceptionType: Fault exception msg\r Traceback (most recent call last):\n "
480492
481493 self .assertEqual (mock_stdout .getvalue (), error_logs )
482494
483495 @patch ("sys.stdout" , new_callable = StringIO )
484- def test_handle_event_request_fault_exception_logging_nomessage_notrace (self , mock_stdout ):
496+ def test_handle_event_request_fault_exception_logging_nomessage_notrace (
497+ self , mock_stdout
498+ ):
485499 def raise_exception_handler (json_input , lambda_context ):
486500 try :
487501 import invalid_module # noqa: F401
@@ -505,7 +519,9 @@ def raise_exception_handler(json_input, lambda_context):
505519 self .assertEqual (mock_stdout .getvalue (), error_logs )
506520
507521 @patch ("sys.stdout" , new_callable = StringIO )
508- def test_handle_event_request_fault_exception_logging_notype_notrace (self , mock_stdout ):
522+ def test_handle_event_request_fault_exception_logging_notype_notrace (
523+ self , mock_stdout
524+ ):
509525 def raise_exception_handler (json_input , lambda_context ):
510526 try :
511527 import invalid_module # noqa: F401
@@ -529,7 +545,9 @@ def raise_exception_handler(json_input, lambda_context):
529545 self .assertEqual (mock_stdout .getvalue (), error_logs )
530546
531547 @patch ("sys.stdout" , new_callable = StringIO )
532- def test_handle_event_request_fault_exception_logging_notype_nomessage (self , mock_stdout ):
548+ def test_handle_event_request_fault_exception_logging_notype_nomessage (
549+ self , mock_stdout
550+ ):
533551 def raise_exception_handler (json_input , lambda_context ):
534552 try :
535553 import invalid_module # noqa: F401
@@ -652,7 +670,9 @@ def __init__(self):
652670 self .assertEqual (actual ["exceptions" ][0 ]["stack" ][0 ]["label" ], "test_method" )
653671 self .assertEqual (actual ["exceptions" ][0 ]["stack" ][0 ]["path" ], "test.py" )
654672 self .assertEqual (actual ["exceptions" ][0 ]["stack" ][0 ]["line" ], 28 )
655- self .assertEqual (actual ["exceptions" ][0 ]["stack" ][1 ]["label" ], "another_test_method" )
673+ self .assertEqual (
674+ actual ["exceptions" ][0 ]["stack" ][1 ]["label" ], "another_test_method"
675+ )
656676 self .assertEqual (actual ["exceptions" ][0 ]["stack" ][1 ]["path" ], "another_test.py" )
657677 self .assertEqual (actual ["exceptions" ][0 ]["stack" ][1 ]["line" ], 2718 )
658678
@@ -662,7 +682,9 @@ class FaultExceptionMatcher(BaseException):
662682 def __init__ (self , msg , exception_type = None , trace_pattern = None ):
663683 self .msg = msg
664684 self .exception_type = exception_type
665- self .trace = trace_pattern if trace_pattern is None else re .compile (trace_pattern )
685+ self .trace = (
686+ trace_pattern if trace_pattern is None else re .compile (trace_pattern )
687+ )
666688
667689 def __eq__ (self , other ):
668690 trace_matches = True
@@ -710,8 +732,12 @@ def test_get_event_handler_import_error(self):
710732
711733 def test_get_event_handler_syntax_error (self ):
712734 importlib .invalidate_caches ()
713- with tempfile .NamedTemporaryFile (suffix = ".py" , dir = "." , delete = False ) as tmp_file :
714- tmp_file .write (b"def syntax_error()\n \t print('syntax error, no colon after function')" )
735+ with tempfile .NamedTemporaryFile (
736+ suffix = ".py" , dir = "." , delete = False
737+ ) as tmp_file :
738+ tmp_file .write (
739+ b"def syntax_error()\n \t print('syntax error, no colon after function')"
740+ )
715741 tmp_file .flush ()
716742
717743 filename_w_ext = os .path .basename (tmp_file .name )
@@ -733,7 +759,9 @@ def test_get_event_handler_syntax_error(self):
733759
734760 def test_get_event_handler_missing_error (self ):
735761 importlib .invalidate_caches ()
736- with tempfile .NamedTemporaryFile (suffix = ".py" , dir = "." , delete = False ) as tmp_file :
762+ with tempfile .NamedTemporaryFile (
763+ suffix = ".py" , dir = "." , delete = False
764+ ) as tmp_file :
737765 tmp_file .write (b"def wrong_handler_name():\n \t print('hello')" )
738766 tmp_file .flush ()
739767
@@ -772,11 +800,15 @@ def test_get_event_handler_build_in_conflict(self):
772800 )
773801
774802 def test_get_event_handler_doesnt_throw_build_in_module_name_slash (self ):
775- response_handler = bootstrap ._get_handler ("tests/test_built_in_module_name/sys.my_handler" )
803+ response_handler = bootstrap ._get_handler (
804+ "tests/test_built_in_module_name/sys.my_handler"
805+ )
776806 response_handler ()
777807
778808 def test_get_event_handler_doent_throw_build_in_module_name (self ):
779- response_handler = bootstrap ._get_handler ("tests.test_built_in_module_name.sys.my_handler" )
809+ response_handler = bootstrap ._get_handler (
810+ "tests.test_built_in_module_name.sys.my_handler"
811+ )
780812 response_handler ()
781813
782814
@@ -946,7 +978,9 @@ def test_log_error_indentation_framed_log_sink(self):
946978
947979 @patch ("sys.stdout" , new_callable = StringIO )
948980 def test_log_error_empty_stacktrace_line_standard_log_sink (self , mock_stdout ):
949- err_to_log = bootstrap .make_error ("Error message" , "ErrorType" , ["line1" , "" , "line2" ])
981+ err_to_log = bootstrap .make_error (
982+ "Error message" , "ErrorType" , ["line1" , "" , "line2" ]
983+ )
950984 bootstrap .log_error (err_to_log , bootstrap .StandardLogSink ())
951985
952986 expected_logged_error = "[ERROR] ErrorType: Error message\r Traceback (most recent call last):\r line1\r \r line2\n "
@@ -1117,7 +1151,9 @@ def test_run(self, mock_runtime_client, mock_handle_event_request):
11171151 ]
11181152
11191153 with self .assertRaises (TypeError ):
1120- bootstrap .run (expected_app_root , expected_handler , expected_lambda_runtime_api_addr )
1154+ bootstrap .run (
1155+ expected_app_root , expected_handler , expected_lambda_runtime_api_addr
1156+ )
11211157
11221158 mock_handle_event_request .assert_called_once ()
11231159
@@ -1140,7 +1176,9 @@ class TestException(Exception):
11401176 mock_sys .exit .side_effect = TestException ("Boom!" )
11411177
11421178 with self .assertRaises (TestException ):
1143- bootstrap .run (expected_app_root , expected_handler , expected_lambda_runtime_api_addr )
1179+ bootstrap .run (
1180+ expected_app_root , expected_handler , expected_lambda_runtime_api_addr
1181+ )
11441182
11451183 mock_sys .exit .assert_called_once_with (1 )
11461184
0 commit comments