Skip to content

Commit 6190eb7

Browse files
authored
Add test for #430 (#548)
1 parent 64cb825 commit 6190eb7

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/strategies/test_include_subclasses.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typing
22
from copy import deepcopy
33
from functools import partial
4-
from typing import Tuple
4+
from typing import List, Tuple
55

66
import pytest
77
from attrs import define
@@ -366,3 +366,28 @@ class Subclass2(Base):
366366
assert genconverter.structure(
367367
{"b": "a", "_type": "Subclass1", "a": {"b": "c", "_type": "Subclass2"}}, Base
368368
) == Subclass1("a", Subclass2("c"))
369+
370+
371+
def test_cycles_classes_2(genconverter: Converter):
372+
"""A cyclic reference case from #430."""
373+
374+
@define
375+
class A:
376+
x: int
377+
378+
@define
379+
class Derived(A):
380+
d: A
381+
382+
include_subclasses(A, genconverter, union_strategy=configure_tagged_union)
383+
384+
assert genconverter.structure(
385+
[
386+
{
387+
"x": 9,
388+
"d": {"x": 99, "d": {"x": 999, "_type": "A"}, "_type": "Derived"},
389+
"_type": "Derived",
390+
}
391+
],
392+
List[A],
393+
) == [Derived(9, Derived(99, A(999)))]

0 commit comments

Comments
 (0)