@@ -67,45 +67,55 @@ def build_and_run_until_breakpoint(self):
6767 def verify_frames_source (
6868 self , frames , main_frame_assembly : bool , other_frame_assembly : bool
6969 ):
70+ self .assertLessEqual (2 , len (frames ), "expect at least 2 frames" )
71+ source_0 = frames [0 ].get ("source" )
72+ source_1 = frames [1 ].get ("source" )
73+ self .assertIsNotNone (source_0 , "Expects a source object in frame 0" )
74+ self .assertIsNotNone (source_1 , "Expects a source object in frame 1" )
75+
76+ # it does not always have a path.
77+ source_0_path : str = source_0 .get ("path" , "" )
78+ source_1_path : str = source_1 .get ("path" , "" )
79+
7080 if other_frame_assembly :
7181 self .assertFalse (
72- frames [ 0 ][ "source" ][ "path" ] .endswith ("other.c" ),
82+ source_0_path .endswith ("other.c" ),
7383 "Expect original source path to not be in unavailable source frame (other.c)" ,
7484 )
7585 self .assertIn (
7686 "sourceReference" ,
77- frames [ 0 ][ "source" ] ,
87+ source_0 ,
7888 "Expect sourceReference to be in unavailable source frame (other.c)" ,
7989 )
8090 else :
8191 self .assertTrue (
82- frames [ 0 ][ "source" ][ "path" ] .endswith ("other.c" ),
92+ source_0_path .endswith ("other.c" ),
8393 "Expect original source path to be in normal source frame (other.c)" ,
8494 )
8595 self .assertNotIn (
8696 "sourceReference" ,
87- frames [ 0 ][ "source" ] ,
97+ source_0 ,
8898 "Expect sourceReference to not be in normal source frame (other.c)" ,
8999 )
90100
91101 if main_frame_assembly :
92102 self .assertFalse (
93- frames [ 1 ][ "source" ][ "path" ] .endswith ("main.c" ),
103+ source_1_path .endswith ("main.c" ),
94104 "Expect original source path to not be in unavailable source frame (main.c)" ,
95105 )
96106 self .assertIn (
97107 "sourceReference" ,
98- frames [ 1 ][ "source" ] ,
108+ source_1 ,
99109 "Expect sourceReference to be in unavailable source frame (main.c)" ,
100110 )
101111 else :
102112 self .assertTrue (
103- frames [ 1 ][ "source" ][ "path" ] .endswith ("main.c" ),
113+ source_1_path .endswith ("main.c" ),
104114 "Expect original source path to be in normal source frame (main.c)" ,
105115 )
106116 self .assertNotIn (
107117 "sourceReference" ,
108- frames [ 1 ][ "source" ] ,
118+ source_1 ,
109119 "Expect sourceReference to not be in normal source code frame (main.c)" ,
110120 )
111121
0 commit comments