MCPcopy
hub / github.com/msgspec/msgspec / test_sequence_cyclic_recursion

Method test_sequence_cyclic_recursion

tests/unit/test_convert.py:973–1002  ·  view source on GitHub ↗
(self, kind)

Source from the content-addressed store, hash-verified

971 reason="CPython 3.12 internal changes prevent testing for recursion issues this way",
972 )
973 def test_sequence_cyclic_recursion(self, kind):
974 depth = 50
975 if kind == "list":
976 typ = List[int]
977 for _ in range(depth):
978 typ = List[typ]
979 elif kind == "tuple":
980 typ = Tuple[int, ...]
981 for _ in range(depth):
982 typ = Tuple[typ, ...]
983 elif kind == "fixtuple":
984 typ = Tuple[int]
985 for _ in range(depth):
986 typ = Tuple[typ]
987 elif kind == "set":
988 typ = FrozenSet[int]
989 for _ in range(depth):
990 typ = FrozenSet[typ]
991
992 class Cache(Struct):
993 value: typ
994
995 msgspec.json.Decoder(Cache)
996
997 arr = []
998 arr.append(arr)
999 msg = {"value": arr}
1000 with pytest.raises(RecursionError):
1001 with max_call_depth(5):
1002 convert(msg, Cache)
1003
1004 @pytest.mark.parametrize("out_type", [list, tuple, set, frozenset])
1005 def test_sequence_constrs(self, out_type):

Callers

nothing calls this directly

Calls 1

max_call_depthFunction · 0.85

Tested by

no test coverage detected