@@ -92,9 +92,16 @@ def _check_function_param_validation(
92
92
rf"The '{ param_name } ' parameter of { func_name } must be .* Got .* instead."
93
93
)
94
94
95
+ err_msg = (
96
+ f"{ func_name } does not raise an informative error message when the "
97
+ f"parameter { param_name } does not have a valid type. If any Python type "
98
+ "is valid, the constraint should be 'no_validation'."
99
+ )
100
+
95
101
# First, check that the error is raised if param doesn't match any valid type.
96
102
with pytest .raises (InvalidParameterError , match = match ):
97
103
func (** {** valid_required_params , param_name : param_with_bad_type })
104
+ pytest .fail (err_msg )
98
105
99
106
# Then, for constraints that are more than a type constraint, check that the
100
107
# error is raised if param does match a valid type but does not match any valid
@@ -107,8 +114,19 @@ def _check_function_param_validation(
107
114
except NotImplementedError :
108
115
continue
109
116
117
+ err_msg = (
118
+ f"{ func_name } does not raise an informative error message when the "
119
+ f"parameter { param_name } does not have a valid value.\n "
120
+ "Constraints should be disjoint. For instance "
121
+ "[StrOptions({'a_string'}), str] is not a acceptable set of "
122
+ "constraint because generating an invalid string for the first "
123
+ "constraint will always produce a valid string for the second "
124
+ "constraint."
125
+ )
126
+
110
127
with pytest .raises (InvalidParameterError , match = match ):
111
128
func (** {** valid_required_params , param_name : bad_value })
129
+ pytest .fail (err_msg )
112
130
113
131
114
132
PARAM_VALIDATION_FUNCTION_LIST = [
0 commit comments