(pydantic_version)
| 1139 | |
| 1140 | |
| 1141 | def test_error_display(pydantic_version): |
| 1142 | v = SchemaValidator( |
| 1143 | core_schema.arguments_schema( |
| 1144 | [ |
| 1145 | core_schema.arguments_parameter('a', core_schema.int_schema()), |
| 1146 | core_schema.arguments_parameter('b', core_schema.int_schema()), |
| 1147 | ] |
| 1148 | ) |
| 1149 | ) |
| 1150 | assert v.validate_python(ArgsKwargs((1,), {'b': '2'})) == ((1,), {'b': 2}) |
| 1151 | |
| 1152 | with pytest.raises(ValidationError) as exc_info: |
| 1153 | v.validate_python(ArgsKwargs((), {'a': 1})) |
| 1154 | |
| 1155 | # insert_assert(exc_info.value.errors(include_url=False)) |
| 1156 | assert exc_info.value.errors(include_url=False) == [ |
| 1157 | { |
| 1158 | 'type': 'missing_argument', |
| 1159 | 'loc': ('b',), |
| 1160 | 'msg': 'Missing required argument', |
| 1161 | 'input': ArgsKwargs((), {'a': 1}), |
| 1162 | } |
| 1163 | ] |
| 1164 | # insert_assert(str(exc_info.value)) |
| 1165 | assert str(exc_info.value) == ( |
| 1166 | '1 validation error for arguments\n' |
| 1167 | 'b\n' |
| 1168 | ' Missing required argument [type=missing_argument, ' |
| 1169 | "input_value=ArgsKwargs((), {'a': 1}), input_type=ArgsKwargs]" |
| 1170 | + ( |
| 1171 | f'\n For further information visit https://errors.pydantic.dev/{pydantic_version}/v/missing_argument' |
| 1172 | if os.environ.get('PYDANTIC_ERRORS_INCLUDE_URL') != 'false' |
| 1173 | else '' |
| 1174 | ) |
| 1175 | ) |
| 1176 | # insert_assert(exc_info.value.json(include_url=False)) |
| 1177 | assert exc_info.value.json(include_url=False) == ( |
| 1178 | '[{"type":"missing_argument","loc":["b"],"msg":"Missing required argument",' |
| 1179 | '"input":"ArgsKwargs((), {\'a\': 1})"}]' |
| 1180 | ) |
| 1181 | |
| 1182 | |
| 1183 | @pytest.mark.parametrize('config_by_alias', [None, True, False]) |
nothing calls this directly
no test coverage detected