2828def test_all_invitation_fields_have_short_and_unique_aliases ():
2929 # all have short alias
3030 all_alias = []
31- for field in _ContentWithShortNames .__fields__ .values ():
31+ for field in _ContentWithShortNames .model_fields .values ():
3232 assert field .alias
3333 assert field .alias not in all_alias
3434 all_alias .append (field .alias )
@@ -38,7 +38,7 @@ def test_import_and_export_invitation_alias_by_alias(
3838 invitation_data : InvitationInputs ,
3939):
4040 expected_content = InvitationContent (
41- ** invitation_data .dict (),
41+ ** invitation_data .model_dump (),
4242 created = datetime .now (tz = timezone .utc ),
4343 )
4444 raw_data = _ContentWithShortNames .serialize (expected_content )
@@ -51,13 +51,13 @@ def test_export_by_alias_produces_smaller_strings(
5151 invitation_data : InvitationInputs ,
5252):
5353 content = InvitationContent (
54- ** invitation_data .dict (),
54+ ** invitation_data .model_dump (),
5555 created = datetime .now (tz = timezone .utc ),
5656 )
5757 raw_data = _ContentWithShortNames .serialize (content )
5858
5959 # export by alias produces smaller strings
60- assert len (raw_data ) < len (content .json ())
60+ assert len (raw_data ) < len (content .model_dump_json ())
6161
6262
6363def test_create_and_decrypt_invitation (
@@ -85,9 +85,9 @@ def test_create_and_decrypt_invitation(
8585 assert isinstance (invitation , InvitationContent )
8686 assert invitation .product is not None
8787
88- expected = invitation_data .dict (exclude_none = True )
88+ expected = invitation_data .model_dump (exclude_none = True )
8989 expected .setdefault ("product" , default_product )
90- assert invitation .dict (exclude = {"created" }, exclude_none = True ) == expected
90+ assert invitation .model_dump (exclude = {"created" }, exclude_none = True ) == expected
9191
9292
9393#
@@ -116,9 +116,9 @@ def test_valid_invitation_code(
116116 default_product = default_product ,
117117 )
118118
119- expected = invitation_data .dict (exclude_none = True )
119+ expected = invitation_data .model_dump (exclude_none = True )
120120 expected .setdefault ("product" , default_product )
121- assert invitation .dict (exclude = {"created" }, exclude_none = True ) == expected
121+ assert invitation .model_dump (exclude = {"created" }, exclude_none = True ) == expected
122122
123123
124124def test_invalid_invitation_encoding (
@@ -176,7 +176,7 @@ class OtherModel(BaseModel):
176176
177177 secret = secret_key .encode ()
178178 other_code = _fernet_encrypt_as_urlsafe_code (
179- data = OtherModel ().json ().encode (), secret_key = secret
179+ data = OtherModel ().model_dump_json ().encode (), secret_key = secret
180180 )
181181
182182 with pytest .raises (ValidationError ):
0 commit comments