From dcf686857c92ec78da6dd044b3012c4106850914 Mon Sep 17 00:00:00 2001 From: Deep Mehta Date: Sat, 24 Jan 2026 15:47:53 +0530 Subject: [PATCH] fix: use hashable types in frozenset test and add dict test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Frozensets can only contain hashable types, so use nested frozensets instead of dicts. Added separate test for dict handling via serialize_cache_key. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests-unit/execution_test/test_cache_provider.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests-unit/execution_test/test_cache_provider.py b/tests-unit/execution_test/test_cache_provider.py index bc321838d..c7484e1a1 100644 --- a/tests-unit/execution_test/test_cache_provider.py +++ b/tests-unit/execution_test/test_cache_provider.py @@ -142,10 +142,12 @@ class TestSerializeCacheKey: def test_complex_nested_structure(self): """Complex nested structures should hash deterministically.""" + # Note: frozensets can only contain hashable types, so we use + # nested frozensets of tuples to represent dict-like structures key = frozenset([ ("node_1", frozenset([ ("input_a", ("tuple", "value")), - ("input_b", {"nested": "dict"}), + ("input_b", frozenset([("nested", "dict")])), ])), ("node_2", frozenset([ ("param", 42), @@ -158,6 +160,18 @@ class TestSerializeCacheKey: assert hash1 == hash2 + def test_dict_in_cache_key(self): + """Dicts passed directly to serialize_cache_key should work.""" + # This tests the _canonicalize function's ability to handle dicts + key = {"node_1": {"input": "value"}, "node_2": 42} + + hash1 = serialize_cache_key(key) + hash2 = serialize_cache_key(key) + + assert hash1 == hash2 + assert isinstance(hash1, bytes) + assert len(hash1) == 32 + class TestContainsNan: """Test contains_nan utility function."""