Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

test: add unit tests for the is_hashable utility (#10113)

eeshsaxenaaec02687eeaf
diff --git a/tests/_utils/test_hashable.py b/tests/_utils/test_hashable.py
new file mode 100644
index 0000000000..b789fae328
--- /dev/null
+++ b/tests/_utils/test_hashable.py
@@ -0,0 +1,30 @@
+# Copyright 2026 Marimo. All rights reserved.
+from __future__ import annotations
+
+from marimo._utils.hashable import is_hashable
+
+
+def test_all_hashable_values() -> None:
+ assert is_hashable(1, "a", (2, 3), None, 3.5)
+
+
+def test_single_unhashable_value() -> None:
+ assert not is_hashable([1, 2, 3])
+ assert not is_hashable({"a": 1})
+ assert not is_hashable({1, 2})
+
+
+def test_mix_of_hashable_and_unhashable() -> None:
+ # A single unhashable value makes the whole call unhashable.
+ assert not is_hashable(1, "ok", [2])
+
+
+def test_no_arguments_is_hashable() -> None:
+ # hash(()) succeeds, so an empty call is considered hashable.
+ assert is_hashable()
+
+
+def test_tuple_nesting_an_unhashable_value() -> None:
+ # Tuples are only hashable if all their contents are.
+ assert not is_hashable((1, [2]))
+ assert is_hashable((1, (2, 3)))