@@ -378,43 +378,37 @@ def test_commit_command_with_config_message_length_limit(
378378
379379@pytest .mark .usefixtures ("staging_is_clean" )
380380@pytest .mark .parametrize (
381- ("test_id" , " body" , "body_length_limit" ),
381+ ("body" , "body_length_limit" ),
382382 [
383- # Basic wrapping - long line gets wrapped
384- (
385- "wrapping" ,
383+ pytest .param (
386384 "This is a very long line that exceeds 72 characters and should be automatically wrapped by the system to fit within the limit" ,
387385 72 ,
386+ id = "wrapping" ,
388387 ),
389- # Line break preservation - multiple lines with \n
390- (
391- "preserves_line_breaks" ,
388+ pytest .param (
392389 "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" ,
393390 72 ,
391+ id = "preserves_line_breaks" ,
394392 ),
395- # Disabled wrapping - limit = 0
396- (
397- "disabled" ,
393+ pytest .param (
398394 "This is a very long line that exceeds 72 characters and should NOT be wrapped when body_length_limit is set to 0" ,
399395 0 ,
396+ id = "disabled" ,
400397 ),
401- # No body - empty string
402- (
403- "no_body" ,
398+ pytest .param (
404399 "" ,
405400 72 ,
401+ id = "no_body" ,
406402 ),
407403 ],
408404)
409405def test_commit_command_body_length_limit (
410- test_id ,
411406 body ,
412407 body_length_limit ,
413408 config ,
414409 success_mock : MockType ,
415410 commit_mock ,
416411 mocker : MockFixture ,
417- file_regression ,
418412):
419413 """Parameterized test for body_length_limit feature with file regression."""
420414 mocker .patch (
@@ -429,24 +423,19 @@ def test_commit_command_body_length_limit(
429423 },
430424 )
431425
432- config .settings ["body_length_limit" ] = body_length_limit
433- commands .Commit (config , {})()
434-
426+ commands .Commit (config , {"body_length_limit" : body_length_limit })()
435427 success_mock .assert_called_once ()
436428 committed_message = commit_mock .call_args [0 ][0 ]
437429
438- # File regression check - uses test_id to create separate files
439- file_regression .check (
440- committed_message ,
441- extension = ".txt" ,
442- basename = f"test_commit_command_body_length_limit_{ test_id } " ,
443- )
430+ lines = committed_message .split ("\n " )
431+ body_lines = lines [2 :] # Skip subject and blank line
444432
445- # Validate line lengths if limit is not 0
446433 if body_length_limit > 0 :
447- lines = committed_message .split ("\n " )
448- body_lines = lines [2 :] # Skip subject and blank line
449434 for line in body_lines :
450435 assert len (line ) <= body_length_limit , (
451436 f"Line exceeds { body_length_limit } chars: '{ line } ' ({ len (line )} chars)"
452437 )
438+ elif body_length_limit == 0 :
439+ assert len (body_lines ) == 1 , (
440+ "Body should not be wrapped when body_length_limit is set to 0"
441+ )
0 commit comments