@@ -529,14 +529,32 @@ def test_issue_pattern(self, runner):
529
529
"pyproject.toml" ,
530
530
extra_config = 'issue_pattern = "\\ \\ d+"' ,
531
531
)
532
- write (
533
- "foo/newsfragments/AAA.BBB.feature.md" ,
534
- "This fragment has an invalid name (should be digits only)" ,
535
- )
536
532
write (
537
533
"foo/newsfragments/123.feature" ,
538
534
"This fragment has a valid name" ,
539
535
)
536
+ write (
537
+ "foo/newsfragments/+abcdefg.feature" ,
538
+ "This fragment has a valid name (no issue name)" ,
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
+ )
540
558
commit ("add stuff" )
541
559
542
560
result = runner .invoke (towncrier_check , ["--compare-with" , "main" ])
@@ -545,11 +563,25 @@ def test_issue_pattern(self, runner):
545
563
"Error: Issue name 'AAA.BBB' does not match the configured pattern, '\\ d+'" ,
546
564
result .output ,
547
565
)
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+"' ,
551
575
)
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+'" ,
554
586
result .output ,
555
587
)
0 commit comments