From fefc73fead29ee7d0d960f8c7c6ec2aec461f320 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Mon, 3 Jun 2024 10:38:28 -0400 Subject: [PATCH] Add comments with former error messages --- tests/unit/test_dataclass_schema.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_dataclass_schema.py b/tests/unit/test_dataclass_schema.py index 6465d92b..499307e6 100644 --- a/tests/unit/test_dataclass_schema.py +++ b/tests/unit/test_dataclass_schema.py @@ -67,27 +67,31 @@ def test_validation(): dct = {"an_attr": "fubar"} with pytest.raises(ValidationError) as excinfo: SomeObject.validate(dct) + # former message: "'name' is a required property" assert ( - excinfo.value.msg + excinfo.value.message == "Invalid value '{'an_attr': 'fubar'}': data must contain ['name'] properties" ) dct = {"name": "testing", "an_int": "some_str"} with pytest.raises(ValidationError) as excinfo: SomeObject.validate(dct) - assert excinfo.value.msg == "Invalid value 'some_str': data.an_int must be integer" + # former message: "'some_str' is not of type 'integer'" + assert excinfo.value.message == "Invalid value 'some_str': data.an_int must be integer" # Note: any field with multiple types (such as Optional[...]) will get the # "cannot be validated by any definition" message. dct = {"name": "testing", "an_enum": "four"} with pytest.raises(ValidationError) as excinfo: SomeObject.validate(dct) + # former message: "'four' is not valid under any of the given schemas" assert ( - excinfo.value.msg + excinfo.value.message == "Invalid value 'four': data.an_enum cannot be validated by any definition" ) dct = {"name": "testing", "a_bool": "True or False"} with pytest.raises(ValidationError) as excinfo: SomeObject.validate(dct) - assert excinfo.value.msg == "Invalid value 'True or False': data.a_bool must be boolean" + # former message: "'True or False' is not of type 'boolean'" + assert excinfo.value.message == "Invalid value 'True or False': data.a_bool must be boolean"