@@ -369,43 +369,37 @@ def test_commit_command_with_config_message_length_limit(
369369
370370@pytest .mark .usefixtures ("staging_is_clean" )
371371@pytest .mark .parametrize (
372- ("test_id" , " body" , "body_length_limit" ),
372+ ("body" , "body_length_limit" ),
373373 [
374- # Basic wrapping - long line gets wrapped
375- (
376- "wrapping" ,
374+ pytest .param (
377375 "This is a very long line that exceeds 72 characters and should be automatically wrapped by the system to fit within the limit" ,
378376 72 ,
377+ id = "wrapping" ,
379378 ),
380- # Line break preservation - multiple lines with \n
381- (
382- "preserves_line_breaks" ,
379+ pytest .param (
383380 "Line1 that is very long and exceeds the limit\n Line2 that is very long and exceeds the limit\n Line3 that is very long and exceeds the limit" ,
384381 72 ,
382+ id = "preserves_line_breaks" ,
385383 ),
386- # Disabled wrapping - limit = 0
387- (
388- "disabled" ,
384+ pytest .param (
389385 "This is a very long line that exceeds 72 characters and should NOT be wrapped when body_length_limit is set to 0" ,
390386 0 ,
387+ id = "disabled" ,
391388 ),
392- # No body - empty string
393- (
394- "no_body" ,
389+ pytest .param (
395390 "" ,
396391 72 ,
392+ id = "no_body" ,
397393 ),
398394 ],
399395)
400396def test_commit_command_body_length_limit (
401- test_id ,
402397 body ,
403398 body_length_limit ,
404399 config ,
405400 success_mock : MockType ,
406401 commit_mock ,
407402 mocker : MockFixture ,
408- file_regression ,
409403):
410404 """Parameterized test for body_length_limit feature with file regression."""
411405 mocker .patch (
@@ -420,24 +414,19 @@ def test_commit_command_body_length_limit(
420414 },
421415 )
422416
423- config .settings ["body_length_limit" ] = body_length_limit
424- commands .Commit (config , {})()
425-
417+ commands .Commit (config , {"body_length_limit" : body_length_limit })()
426418 success_mock .assert_called_once ()
427419 committed_message = commit_mock .call_args [0 ][0 ]
428420
429- # File regression check - uses test_id to create separate files
430- file_regression .check (
431- committed_message ,
432- extension = ".txt" ,
433- basename = f"test_commit_command_body_length_limit_{ test_id } " ,
434- )
421+ lines = committed_message .split ("\n " )
422+ body_lines = lines [2 :] # Skip subject and blank line
435423
436- # Validate line lengths if limit is not 0
437424 if body_length_limit > 0 :
438- lines = committed_message .split ("\n " )
439- body_lines = lines [2 :] # Skip subject and blank line
440425 for line in body_lines :
441426 assert len (line ) <= body_length_limit , (
442427 f"Line exceeds { body_length_limit } chars: '{ line } ' ({ len (line )} chars)"
443428 )
429+ elif body_length_limit == 0 :
430+ assert len (body_lines ) == 1 , (
431+ "Body should not be wrapped when body_length_limit is set to 0"
432+ )
0 commit comments