@@ -1313,32 +1313,40 @@ def test_co_positions(self):
13131313 ]
13141314 self .assertEqual (positions , expected )
13151315
1316+ named_positions = [
1317+ (pos .lineno , pos .end_lineno , pos .col_offset , pos .end_col_offset )
1318+ for pos in positions
1319+ ]
1320+ self .assertEqual (named_positions , expected )
1321+
13161322 @requires_debug_ranges ()
13171323 def test_co_positions_missing_info (self ):
13181324 code = compile ('x, y, z' , '<test>' , 'exec' )
13191325 code_without_column_table = code .replace (co_columntable = b'' )
13201326 actual = dis .get_instructions (code_without_column_table )
13211327 for instruction in actual :
13221328 with self .subTest (instruction = instruction ):
1323- start_line , end_line , start_offset , end_offset = instruction .positions
1329+ positions = instruction .positions
1330+ self .assertEqual (len (positions ), 4 )
13241331 if instruction .opname == "RESUME" :
13251332 continue
1326- assert start_line == 1
1327- assert end_line == 1
1328- assert start_offset is None
1329- assert end_offset is None
1333+ self . assertEqual ( positions . lineno , 1 )
1334+ self . assertEqual ( positions . end_lineno , 1 )
1335+ self . assertIsNone ( positions . col_offset )
1336+ self . assertIsNone ( positions . end_col_offset )
13301337
13311338 code_without_endline_table = code .replace (co_endlinetable = b'' )
13321339 actual = dis .get_instructions (code_without_endline_table )
13331340 for instruction in actual :
13341341 with self .subTest (instruction = instruction ):
1335- start_line , end_line , start_offset , end_offset = instruction .positions
1342+ positions = instruction .positions
1343+ self .assertEqual (len (positions ), 4 )
13361344 if instruction .opname == "RESUME" :
13371345 continue
1338- assert start_line == 1
1339- assert end_line is None
1340- assert start_offset is not None
1341- assert end_offset is not None
1346+ self . assertEqual ( positions . lineno , 1 )
1347+ self . assertIsNone ( positions . end_lineno )
1348+ self . assertIsNotNone ( positions . col_offset )
1349+ self . assertIsNotNone ( positions . end_col_offset )
13421350
13431351# get_instructions has its own tests above, so can rely on it to validate
13441352# the object oriented API
0 commit comments