Skip to content

Commit

Permalink
Add tags and nested tags to ref leak test
Browse files Browse the repository at this point in the history
It appears that without additional fixes the hash function (invoked
during building a dict of tags) does not incur reference leaks (at least
not detectable)
  • Loading branch information
nielstron authored and Sekenre committed Nov 28, 2022
1 parent c28a6d6 commit 0b31234
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/ref_leak_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import objgraph

import cbor2


def import_cbor2():
# Similar hack to that used in tests/conftest to get separate C and Python
Expand Down Expand Up @@ -84,6 +86,8 @@ class Module:
[{"name": "Foo", "species": "cat", "dob": datetime(2013, 5, 20), "weight": 4.1}]
* 100,
),
("tag", {}, c_cbor2.CBORTag(1, 1)),
("nestedtag", {}, {c_cbor2.CBORTag(1, 1) : 1}),
]

Leaks = namedtuple("Leaks", ("count", "comparison"))
Expand Down Expand Up @@ -237,7 +241,7 @@ def main():
sys.stderr.write("Testing")
sys.stderr.flush()
for name, kwargs, value in TEST_VALUES:
encoded = py_cbor2.dumps(value, **kwargs)
encoded = c_cbor2.dumps(value, **kwargs)
results[name] = Result(
encoding=test(lambda: c_cbor2.dumps(value, **kwargs)),
decoding=test(lambda: c_cbor2.loads(encoded)),
Expand Down

0 comments on commit 0b31234

Please sign in to comment.