@@ -643,7 +643,7 @@ def test_disallowed_grouping__two_top_groups_on_left(self):
643
643
self .assertEqual (out , expected_msg )
644
644
645
645
def test_disallowed_grouping__two_top_groups_on_right (self ):
646
- self .parse_function_should_fail ("""
646
+ out = self .parse_function_should_fail ("""
647
647
module foo
648
648
foo.two_top_groups_on_right
649
649
param: int
@@ -654,9 +654,14 @@ def test_disallowed_grouping__two_top_groups_on_right(self):
654
654
group2 : int
655
655
]
656
656
""" )
657
+ msg = (
658
+ "Function two_top_groups_on_right has an unsupported group "
659
+ "configuration. (Unexpected state 6.b)"
660
+ )
661
+ self .assertIn (msg , out )
657
662
658
663
def test_disallowed_grouping__parameter_after_group_on_right (self ):
659
- self .parse_function_should_fail ("""
664
+ out = self .parse_function_should_fail ("""
660
665
module foo
661
666
foo.parameter_after_group_on_right
662
667
param: int
@@ -667,9 +672,14 @@ def test_disallowed_grouping__parameter_after_group_on_right(self):
667
672
group2 : int
668
673
]
669
674
""" )
675
+ msg = (
676
+ "Function parameter_after_group_on_right has an unsupported group "
677
+ "configuration. (Unexpected state 6.a)"
678
+ )
679
+ self .assertIn (msg , out )
670
680
671
681
def test_disallowed_grouping__group_after_parameter_on_left (self ):
672
- self .parse_function_should_fail ("""
682
+ out = self .parse_function_should_fail ("""
673
683
module foo
674
684
foo.group_after_parameter_on_left
675
685
[
@@ -680,9 +690,14 @@ def test_disallowed_grouping__group_after_parameter_on_left(self):
680
690
]
681
691
param: int
682
692
""" )
693
+ msg = (
694
+ "Function group_after_parameter_on_left has an unsupported group "
695
+ "configuration. (Unexpected state 2.b)"
696
+ )
697
+ self .assertIn (msg , out )
683
698
684
699
def test_disallowed_grouping__empty_group_on_left (self ):
685
- self .parse_function_should_fail ("""
700
+ out = self .parse_function_should_fail ("""
686
701
module foo
687
702
foo.empty_group
688
703
[
@@ -692,9 +707,14 @@ def test_disallowed_grouping__empty_group_on_left(self):
692
707
]
693
708
param: int
694
709
""" )
710
+ msg = (
711
+ "Function empty_group has an empty group.\n "
712
+ "All groups must contain at least one parameter."
713
+ )
714
+ self .assertIn (msg , out )
695
715
696
716
def test_disallowed_grouping__empty_group_on_right (self ):
697
- self .parse_function_should_fail ("""
717
+ out = self .parse_function_should_fail ("""
698
718
module foo
699
719
foo.empty_group
700
720
param: int
@@ -704,6 +724,11 @@ def test_disallowed_grouping__empty_group_on_right(self):
704
724
group2 : int
705
725
]
706
726
""" )
727
+ msg = (
728
+ "Function empty_group has an empty group.\n "
729
+ "All groups must contain at least one parameter."
730
+ )
731
+ self .assertIn (msg , out )
707
732
708
733
def test_no_parameters (self ):
709
734
function = self .parse_function ("""
@@ -732,69 +757,60 @@ class foo.Bar "unused" "notneeded"
732
757
self .assertEqual (1 , len (function .parameters ))
733
758
734
759
def test_illegal_module_line (self ):
735
- self .parse_function_should_fail ("""
760
+ out = self .parse_function_should_fail ("""
736
761
module foo
737
762
foo.bar => int
738
763
/
739
764
""" )
765
+ msg = "Illegal function name: foo.bar => int"
766
+ self .assertIn (msg , out )
740
767
741
768
def test_illegal_c_basename (self ):
742
- self .parse_function_should_fail ("""
769
+ out = self .parse_function_should_fail ("""
743
770
module foo
744
771
foo.bar as 935
745
772
/
746
773
""" )
774
+ msg = "Illegal C basename: 935"
775
+ self .assertIn (msg , out )
747
776
748
777
def test_single_star (self ):
749
- self .parse_function_should_fail ("""
750
- module foo
751
- foo.bar
752
- *
753
- *
754
- """ )
755
-
756
- def test_parameters_required_after_star_without_initial_parameters_or_docstring (self ):
757
- self .parse_function_should_fail ("""
758
- module foo
759
- foo.bar
760
- *
761
- """ )
762
-
763
- def test_parameters_required_after_star_without_initial_parameters_with_docstring (self ):
764
- self .parse_function_should_fail ("""
778
+ out = self .parse_function_should_fail ("""
765
779
module foo
766
780
foo.bar
767
781
*
768
- Docstring here.
769
- """ )
770
-
771
- def test_parameters_required_after_star_with_initial_parameters_without_docstring (self ):
772
- self .parse_function_should_fail ("""
773
- module foo
774
- foo.bar
775
- this: int
776
782
*
777
783
""" )
784
+ self .assertIn ("Function bar uses '*' more than once." , out )
778
785
779
- def test_parameters_required_after_star_with_initial_parameters_and_docstring (self ):
780
- self .parse_function_should_fail ("""
781
- module foo
782
- foo.bar
783
- this: int
784
- *
785
- Docstring.
786
- """ )
786
+ def test_parameters_required_after_star (self ):
787
+ dataset = (
788
+ "module foo\n foo.bar\n *" ,
789
+ "module foo\n foo.bar\n *\n Docstring here." ,
790
+ "module foo\n foo.bar\n this: int\n *" ,
791
+ "module foo\n foo.bar\n this: int\n *\n Docstring." ,
792
+ )
793
+ msg = "Function bar specifies '*' without any parameters afterwards."
794
+ for block in dataset :
795
+ with self .subTest (block = block ):
796
+ out = self .parse_function_should_fail (block )
797
+ self .assertIn (msg , out )
787
798
788
799
def test_single_slash (self ):
789
- self .parse_function_should_fail ("""
800
+ out = self .parse_function_should_fail ("""
790
801
module foo
791
802
foo.bar
792
803
/
793
804
/
794
805
""" )
806
+ msg = (
807
+ "Function bar has an unsupported group configuration. "
808
+ "(Unexpected state 0.d)"
809
+ )
810
+ self .assertIn (msg , out )
795
811
796
812
def test_mix_star_and_slash (self ):
797
- self .parse_function_should_fail ("""
813
+ out = self .parse_function_should_fail ("""
798
814
module foo
799
815
foo.bar
800
816
x: int
@@ -803,14 +819,24 @@ def test_mix_star_and_slash(self):
803
819
z: int
804
820
/
805
821
""" )
822
+ msg = (
823
+ "Function bar mixes keyword-only and positional-only parameters, "
824
+ "which is unsupported."
825
+ )
826
+ self .assertIn (msg , out )
806
827
807
828
def test_parameters_not_permitted_after_slash_for_now (self ):
808
- self .parse_function_should_fail ("""
829
+ out = self .parse_function_should_fail ("""
809
830
module foo
810
831
foo.bar
811
832
/
812
833
x: int
813
834
""" )
835
+ msg = (
836
+ "Function bar has an unsupported group configuration. "
837
+ "(Unexpected state 0.d)"
838
+ )
839
+ self .assertIn (msg , out )
814
840
815
841
def test_parameters_no_more_than_one_vararg (self ):
816
842
expected_msg = (
0 commit comments