Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/asynchronous/test_custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import datetime
import gc
import sys
import tempfile
from collections import OrderedDict
Expand Down Expand Up @@ -427,9 +428,15 @@ def test_infinite_loop_exceeds_max_recursion_depth(self):
type_registry=TypeRegistry([self.B2A()], fallback_encoder=self.fallback_encoder_A2B)
)

# Raises max recursion depth exceeded error
with self.assertRaises(RuntimeError):
encode({"x": self.TypeA(100)}, codec_options=codecopts)
# GC while the stack is exhausted may trigger an unraisable RecursionError that causes a failure
gc.collect()
gc.disable()
try:
# Raises max recursion depth exceeded error
with self.assertRaises(RuntimeError):
encode({"x": self.TypeA(100)}, codec_options=codecopts)
finally:
gc.enable()
Comment thread
NoahStapp marked this conversation as resolved.


class TestTypeRegistry(unittest.TestCase):
Expand Down
13 changes: 10 additions & 3 deletions test/test_custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import datetime
import gc
import sys
import tempfile
from collections import OrderedDict
Expand Down Expand Up @@ -427,9 +428,15 @@ def test_infinite_loop_exceeds_max_recursion_depth(self):
type_registry=TypeRegistry([self.B2A()], fallback_encoder=self.fallback_encoder_A2B)
)

# Raises max recursion depth exceeded error
with self.assertRaises(RuntimeError):
encode({"x": self.TypeA(100)}, codec_options=codecopts)
# GC while the stack is exhausted may trigger an unraisable RecursionError that causes a failure
gc.collect()
gc.disable()
try:
# Raises max recursion depth exceeded error
with self.assertRaises(RuntimeError):
encode({"x": self.TypeA(100)}, codec_options=codecopts)
finally:
gc.enable()
Comment thread
NoahStapp marked this conversation as resolved.


class TestTypeRegistry(unittest.TestCase):
Expand Down
Loading