Skip to content

Commit 8d576af

Browse files
committed
[FIX] tests
1 parent a6d46b8 commit 8d576af

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

samples/openapi3/client/petstore/python/tests/test_model.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,17 @@ def test_oneof_nested_from_dict(self):
143143

144144
def test_oneof_nested_from_json_invalid(self):
145145
try:
146-
nested2 = petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}')
146+
petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}')
147147
except ValueError as e:
148-
self.assertTrue("'e' is not a valid EnumString1, 'e' is not a valid EnumString" in str(e))
148+
# pydantic_core._pydantic_core.ValidationError: 2 validation errors for WithNestedOneOf
149+
# nested_oneof_enum_string.str-enum[EnumString1]
150+
# Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str]
151+
# For further information visit https://errors.pydantic.dev/2.12/v/enum
152+
# nested_oneof_enum_string.str-enum[EnumString2]
153+
# Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str]
154+
# For further information visit https://errors.pydantic.dev/2.12/v/enum
155+
self.assertIn("Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str]", str(e))
156+
self.assertIn("Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str]", str(e))
149157

150158
def test_oneof_enum_string(self):
151159
# test the constructor
@@ -387,8 +395,8 @@ def test_inline_enum_validator(self):
387395
try:
388396
self.pet.status = "error"
389397
self.assertTrue(False, "should have failed with 'invalid status' error") # this line shouldn't execute
390-
except ValueError as e:
391-
self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e))
398+
except ValidationError as e:
399+
self.assertIn("Input should be 'available', 'pending' or 'sold' [type=literal_error, input_value='error', input_type=str]", str(e))
392400

393401
def test_constraints(self):
394402
rgb = [128, 128, 128]

0 commit comments

Comments
 (0)