@@ -273,25 +273,20 @@ def inner():
273273 except KeyError :
274274 original_tb = sys .exc_info ()[2 ]
275275
276- # Wrap with tblib
277276 tb_wrapper = Traceback (original_tb )
278277
279- # Check that column info was captured
280278 inner_frame = tb_wrapper .tb_next
281279 assert inner_frame .tb_colno is not None , 'tb_colno should be captured'
282280 assert inner_frame .tb_end_colno is not None , 'tb_end_colno should be captured'
283281
284- # Reconstruct the traceback
285282 reconstructed_tb = tb_wrapper .as_traceback ()
286283
287- # Format both tracebacks
288284 original_output = io .StringIO ()
289285 traceback .print_exception (KeyError , KeyError ('b' ), original_tb , file = original_output )
290286
291287 reconstructed_output = io .StringIO ()
292288 traceback .print_exception (KeyError , KeyError ('b' ), reconstructed_tb , file = reconstructed_output )
293289
294- # Compare line by line
295290 original_lines = original_output .getvalue ().splitlines ()
296291 reconstructed_lines = reconstructed_output .getvalue ().splitlines ()
297292
@@ -319,14 +314,12 @@ def inner():
319314 tb_wrapper = Traceback (original_tb )
320315 tb_dict = tb_wrapper .as_dict ()
321316
322- # Check that column info is in the dict
323317 inner_dict = tb_dict ['tb_next' ]
324318 assert 'tb_colno' in inner_dict , 'tb_colno should be in dict'
325319 assert 'tb_end_colno' in inner_dict , 'tb_end_colno should be in dict'
326320 assert inner_dict ['tb_colno' ] is not None
327321 assert inner_dict ['tb_end_colno' ] is not None
328322
329- # Reconstruct from dict
330323 tb_from_dict = Traceback .from_dict (tb_dict )
331324 assert tb_from_dict .tb_next .tb_colno == inner_dict ['tb_colno' ]
332325 assert tb_from_dict .tb_next .tb_end_colno == inner_dict ['tb_end_colno' ]
@@ -359,7 +352,6 @@ def inner():
359352
360353def test_caret_position_without_column_info ():
361354 """Test that reconstruction works when column info is not available."""
362- # Create a traceback from string (no column info)
363355 tb = Traceback .from_string (
364356 """
365357Traceback (most recent call last):
@@ -369,11 +361,9 @@ def test_caret_position_without_column_info():
369361"""
370362 )
371363
372- # Should have None for column info
373364 assert tb .tb_colno is None
374365 assert tb .tb_end_colno is None
375366
376- # Should still reconstruct successfully
377367 reconstructed = tb .as_traceback ()
378368 assert reconstructed is not None
379369 assert reconstructed .tb_lineno == 10
@@ -410,22 +400,19 @@ def inner():
410400
411401def test_traceback_from_string_invalid ():
412402 """Test TracebackParseError is raised for invalid input."""
413- # String without any frames should raise TracebackParseError
414403 with pytest .raises (TracebackParseError , match = 'Could not find any frames' ):
415404 Traceback .from_string ('Not a valid traceback' )
416405
417406
418407@pytest .mark .skipif (not has_column_positions , reason = 'Column positions require Python 3.11+' )
419408def test_get_code_position_edge_cases ():
420409 """Test _get_code_position edge cases for coverage."""
421- # Test with code object lacking co_positions attribute
422410 class FakeCode :
423411 pass
424412
425413 result = _get_code_position (FakeCode (), 0 )
426414 assert result == (None , None , None , None )
427415
428- # Test with negative instruction index
429416 code = compile ('x = 1' , '<test>' , 'exec' )
430417 result = _get_code_position (code , - 1 )
431418 assert result == (None , None , None , None )
@@ -435,19 +422,15 @@ class FakeCode:
435422def test_linetable_functions_with_none ():
436423 """Test linetable creation functions handle None values correctly."""
437424 if sys .implementation .name == 'pypy' :
438- # Test with None colno
439425 result = _make_pypy_linetable_with_positions (None , 10 , 5 )
440426 assert isinstance (result , bytes )
441427
442- # Test with None end_colno
443428 result = _make_pypy_linetable_with_positions (5 , None , 5 )
444429 assert isinstance (result , bytes )
445430 else :
446- # Test with None colno
447431 result = _make_linetable_with_positions (None , 10 )
448432 assert isinstance (result , bytes )
449433
450- # Test with None end_colno
451434 result = _make_linetable_with_positions (5 , None )
452435 assert isinstance (result , bytes )
453436
0 commit comments