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