@@ -334,3 +334,28 @@ def test_stylecheck_with_custom_line_length():
334334 # If it returns 0, the test expects layout issues but none were found
335335 # This is acceptable as the formatter may handle it without reporting issues
336336 assert result_code in [0 , 1 ]
337+
338+
339+ def test_line_numbers_in_warnings (caplog ):
340+ """Test that the style checker reports correct line numbers for smushed lists and bold headers."""
341+ file_name = "smushed_doc.robot"
342+ robot_file_original = INPUT_DIR / file_name
343+ if OUTPUT_DIR .exists ():
344+ shutil .rmtree (OUTPUT_DIR )
345+ OUTPUT_DIR .mkdir ()
346+ robot_file_to_fix = OUTPUT_DIR / file_name
347+ shutil .copy (robot_file_original , robot_file_to_fix )
348+
349+ sys .argv = ["robot2rst" , "stylecheck" , str (robot_file_to_fix ), "--enable-bold-headers" , "--fix" ]
350+
351+ with caplog .at_level (logging .WARNING ):
352+ robot2rst_main ()
353+
354+ log_text = caplog .text
355+ assert (f"{ robot_file_to_fix } :8: Smushed bold header detected: '**A smushed bold header**'. "
356+ "Added blank lines to ensure it is treated as a title." ) in log_text
357+ assert (f"{ robot_file_to_fix } :13: Smushed bold header detected: '**Another smushed bold header**'. "
358+ "Added blank lines to ensure it is treated as a title." ) in log_text
359+ assert f"{ robot_file_to_fix } :3: Fixed possible 'smushed' lists" in log_text
360+ assert f"{ robot_file_to_fix } :6: Bullet list ends without a blank line; unexpected unindent." in log_text
361+ assert f"{ robot_file_to_fix } :16: Bullet list ends without a blank line; unexpected unindent." in log_text
0 commit comments