Skip to content

Commit df4293b

Browse files
Update v0.1.4
1 parent 0111ff1 commit df4293b

3 files changed

Lines changed: 73 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## v 0.1.4
4+
5+
Date: 2026-07-26
6+
7+
- Formal update: Added node_list.json; Adapted project file
8+
- Added tests
9+
10+
311
## v 0.1.3
412

513
Date: 2026-07-25

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfymath-ng"
3-
version = "0.1.3"
4-
description = "A maintained fork of ComfyMath providing math nodes for ComfyUI"
3+
version = "0.1.4"
4+
description = "A maintained fork of ComfyMath, provides Math Nodes for ComfyUI. Boolean Logic, Integer Arithmetic, Floating Point Arithmetic and Functions, Vec2, Vec3, and Vec4 Arithmetic and Functions"
55
authors = [
66
"Evan Spearman <evan@spearman.mb.ca>",
77
"Raphael Stoeckli <https://github.com/rabanti-github>",

‎tests/test_node_list.py‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import importlib.util
2+
import json
3+
import pathlib
4+
import sys
5+
import unittest
6+
from typing import Any
7+
8+
9+
REPO_ROOT = pathlib.Path(__file__).resolve().parents[1]
10+
NODE_LIST_PATH = REPO_ROOT / "node_list.json"
11+
12+
13+
def load_root_node_class_mappings() -> dict[str, Any]:
14+
parent = str(REPO_ROOT.parent)
15+
if parent not in sys.path:
16+
sys.path.insert(0, parent)
17+
18+
spec = importlib.util.spec_from_file_location(
19+
"ComfyMath",
20+
REPO_ROOT / "__init__.py",
21+
submodule_search_locations=[str(REPO_ROOT)],
22+
)
23+
if spec is None or spec.loader is None:
24+
raise RuntimeError("Unable to load root ComfyMath package")
25+
26+
module = importlib.util.module_from_spec(spec)
27+
sys.modules[spec.name] = module
28+
spec.loader.exec_module(module)
29+
return module.NODE_CLASS_MAPPINGS
30+
31+
32+
def reject_duplicate_keys(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
33+
result: dict[str, Any] = {}
34+
for key, value in pairs:
35+
if key in result:
36+
raise ValueError(f"Duplicate node_list.json key: {key}")
37+
result[key] = value
38+
return result
39+
40+
41+
class NodeListValidationTest(unittest.TestCase):
42+
def test_node_list_matches_effective_root_node_class_mappings(self) -> None:
43+
with NODE_LIST_PATH.open(encoding="utf-8") as node_list_file:
44+
node_list = json.load(
45+
node_list_file, object_pairs_hook=reject_duplicate_keys
46+
)
47+
48+
self.assertIs(type(node_list), dict)
49+
for node_key, description in node_list.items():
50+
with self.subTest(node_key=node_key):
51+
self.assertIs(type(node_key), str)
52+
self.assertIs(type(description), str)
53+
self.assertTrue(description.strip())
54+
55+
registered_nodes = load_root_node_class_mappings()
56+
57+
self.assertEqual(list(node_list), list(registered_nodes))
58+
self.assertEqual(set(node_list), set(registered_nodes))
59+
self.assertEqual(len(node_list), len(registered_nodes))
60+
61+
62+
if __name__ == "__main__":
63+
unittest.main()

0 commit comments

Comments
 (0)