From d158cbfb3fc702e0d40091c1200873e05f3a1d85 Mon Sep 17 00:00:00 2001 From: Kevin Modzelewski Date: Mon, 7 Mar 2022 18:01:05 -0500 Subject: [PATCH] Update the test suite to work on Pyston The library itself already works, but some of the debugging features are slightly different in Pyston: - There is no tracemalloc library - sys.setrecursionlimit sets a lower bound not an exact count --- tests/test_circular.py | 10 +++++++++- tests/test_memory_leaks.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_circular.py b/tests/test_circular.py index 07c66a3..d76d921 100644 --- a/tests/test_circular.py +++ b/tests/test_circular.py @@ -54,7 +54,15 @@ def test_max_recursion_depth(dumps): dumps(root) rl = sys.getrecursionlimit() - sys.setrecursionlimit(500) + + if hasattr(sys, "pyston_version_info"): + # In Pyston setrecursionlimit() sets a lower bound on the number of frames, + # not an exact count. So set the limit lower: + sys.setrecursionlimit(100) + else: + # Otherwise set it to the exact value: + sys.setrecursionlimit(500) + try: with pytest.raises(expected_exception): dumps(root) diff --git a/tests/test_memory_leaks.py b/tests/test_memory_leaks.py index 8d2116d..015ba73 100644 --- a/tests/test_memory_leaks.py +++ b/tests/test_memory_leaks.py @@ -9,11 +9,12 @@ import io import datetime import gc -import tracemalloc import pytest import rapidjson as rj +tracemalloc = pytest.importorskip("tracemalloc") + def object_hook(td): if '__td__' in td: