@@ -529,14 +529,32 @@ def test_issue_pattern(self, runner):
529529 "pyproject.toml" ,
530530 extra_config = 'issue_pattern = "\\ \\ d+"' ,
531531 )
532- write (
533- "foo/newsfragments/AAA.BBB.feature.md" ,
534- "This fragment has an invalid name (should be digits only)" ,
535- )
536532 write (
537533 "foo/newsfragments/123.feature" ,
538534 "This fragment has a valid name" ,
539535 )
536+ write (
537+ "foo/newsfragments/+abcdefg.feature" ,
538+ "This fragment has a valid name (orphan fragment)" ,
539+ )
540+ commit ("add stuff" )
541+
542+ result = runner .invoke (towncrier_check , ["--compare-with" , "main" ])
543+ self .assertEqual (0 , result .exit_code , result .output )
544+
545+ @with_isolated_runner
546+ def test_issue_pattern_invalid_with_suffix (self , runner ):
547+ """
548+ Fails if an issue name goes against the configured pattern.
549+ """
550+ create_project (
551+ "pyproject.toml" ,
552+ extra_config = 'issue_pattern = "\\ \\ d+"' ,
553+ )
554+ write (
555+ "foo/newsfragments/AAA.BBB.feature.md" ,
556+ "This fragment has an invalid name (should be digits only)" ,
557+ )
540558 commit ("add stuff" )
541559
542560 result = runner .invoke (towncrier_check , ["--compare-with" , "main" ])
@@ -545,11 +563,25 @@ def test_issue_pattern(self, runner):
545563 "Error: Issue name 'AAA.BBB' does not match the configured pattern, '\\ d+'" ,
546564 result .output ,
547565 )
548- self .assertNotIn (
549- "Error: Issue '123' does not match the configured pattern, '\\ d+'" ,
550- result .output ,
566+
567+ @with_isolated_runner
568+ def test_issue_pattern_invalid (self , runner ):
569+ """
570+ Fails if an issue name goes against the configured pattern.
571+ """
572+ create_project (
573+ "pyproject.toml" ,
574+ extra_config = 'issue_pattern = "\\ \\ d+"' ,
551575 )
552- self .assertNotIn (
553- "Error: Issue '123.feature' does not match the configured pattern, '\\ d+'" ,
576+ write (
577+ "foo/newsfragments/AAA.BBB.feature" ,
578+ "This fragment has an invalid name (should be digits only)" ,
579+ )
580+ commit ("add stuff" )
581+
582+ result = runner .invoke (towncrier_check , ["--compare-with" , "main" ])
583+ self .assertEqual (1 , result .exit_code , result .output )
584+ self .assertIn (
585+ "Error: Issue name 'AAA.BBB' does not match the configured pattern, '\\ d+'" ,
554586 result .output ,
555587 )
0 commit comments