Skip to content

Commit

Permalink
3.10 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Apr 9, 2022
1 parent cb16c23 commit 75d1285
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions tests/metadata/test_genconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def test_310_union_field_roundtrip(cl_and_vals_a, cl_and_vals_b, strat):
converter = Converter(unstruct_strat=strat)
cl_a, vals_a, kwargs_a = cl_and_vals_a
cl_b, _, _ = cl_and_vals_b
assume(strat is UnstructureStrategy.AS_DICT or not kwargs_a)
a_field_names = {a.name for a in fields(cl_a)}
b_field_names = {a.name for a in fields(cl_b)}
assume(a_field_names)
Expand Down Expand Up @@ -332,13 +333,13 @@ def test_310_optional_field_roundtrip(cl_and_vals):
Classes with optional fields can be unstructured and structured.
"""
converter = Converter()
cl, vals = cl_and_vals
cl, vals, kwargs = cl_and_vals

@define
class C:
a: cl | None

inst = C(a=cl(*vals))
inst = C(a=cl(*vals, **kwargs))
assert inst == converter.structure(converter.unstructure(inst), C)

inst = C(a=None)
Expand Down
9 changes: 5 additions & 4 deletions tests/metadata/test_roundtrips.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ def test_310_union_field_roundtrip(cl_and_vals_a, cl_and_vals_b, strat):
Classes with union fields can be unstructured and structured.
"""
converter = Converter(unstruct_strat=strat)
cl_a, vals_a = cl_and_vals_a
cl_b, vals_b = cl_and_vals_b
cl_a, vals_a, kwargs_a = cl_and_vals_a
cl_b, vals_b, _ = cl_and_vals_b
assume(strat is UnstructureStrategy.AS_DICT or not kwargs_a)
a_field_names = {a.name for a in fields(cl_a)}
b_field_names = {a.name for a in fields(cl_b)}
assume(a_field_names)
Expand Down Expand Up @@ -180,13 +181,13 @@ def test_310_optional_field_roundtrip(cl_and_vals):
Classes with optional fields can be unstructured and structured.
"""
converter = Converter()
cl, vals = cl_and_vals
cl, vals, kwargs = cl_and_vals

@define
class C:
a: cl | None

inst = C(a=cl(*vals))
inst = C(a=cl(*vals, **kwargs))
assert inst == converter.structure(converter.unstructure(inst), C)

inst = C(a=None)
Expand Down

0 comments on commit 75d1285

Please sign in to comment.