From 59abd5e385169ef184bb1e76e93697c63807dc77 Mon Sep 17 00:00:00 2001 From: yukinarit Date: Sun, 8 Oct 2023 23:03:33 +0900 Subject: [PATCH] Add test of alias + rename_all --- tests/test_basics.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_basics.py b/tests/test_basics.py index d3efd01c..c1e87796 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -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: