Skip to content

Commit

Permalink
Merge pull request #528 from JustAnotherArchivist/test-sorted-key-ref…
Browse files Browse the repository at this point in the history
…-counts

Add test for key ref counts with sort_keys enabled
  • Loading branch information
hugovk committed Apr 13, 2022
2 parents 62dec8d + 97fceb6 commit 19c21d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_ujson.py
Expand Up @@ -240,13 +240,14 @@ def test_encode_dict_values_ref_counting():
hasattr(sys, "pypy_version_info"), reason="PyPy uses incompatible GC"
)
@pytest.mark.parametrize("key", ["key", b"key", 1, True, None])
def test_encode_dict_key_ref_counting(key):
@pytest.mark.parametrize("sort_keys", [False, True])
def test_encode_dict_key_ref_counting(key, sort_keys):
import gc

gc.collect()
data = {key: "abc"}
ref_count = sys.getrefcount(key)
ujson.dumps(data)
ujson.dumps(data, sort_keys=sort_keys)
assert ref_count == sys.getrefcount(key)


Expand Down

0 comments on commit 19c21d4

Please sign in to comment.