Skip to content

Commit

Permalink
Add test of alias + rename_all
Browse files Browse the repository at this point in the history
  • Loading branch information
yukinarit committed Oct 9, 2023
1 parent d356168 commit 59abd5e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,17 @@ class Foo:
assert ff.a == 10


def test_rename_all_and_alias():
@serde.serde(rename_all="pascalcase")
class Foo:
a_field: int = serde.field(alias=["b_field"])

f = Foo(1)
assert '{"AField":1}' == serde.json.to_json(f)
ff = serde.json.from_json(Foo, '{"b_field":1}') # alias is not renamed
assert f == ff


def test_default_and_alias():
@serde.serde
class Foo:
Expand Down

0 comments on commit 59abd5e

Please sign in to comment.