You've already forked HeurAMS-legacy
fix
This commit is contained in:
@@ -9,7 +9,9 @@ class TestNucleon(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
"""测试初始化"""
|
||||
nucleon = Nucleon("test_id", {"content": "hello", "note": "world"}, {"author": "test"})
|
||||
nucleon = Nucleon(
|
||||
"test_id", {"content": "hello", "note": "world"}, {"author": "test"}
|
||||
)
|
||||
self.assertEqual(nucleon.ident, "test_id")
|
||||
self.assertEqual(nucleon.payload, {"content": "hello", "note": "world"})
|
||||
self.assertEqual(nucleon.metadata, {"author": "test"})
|
||||
@@ -27,7 +29,7 @@ class TestNucleon(unittest.TestCase):
|
||||
self.assertEqual(nucleon["ident"], "test_id")
|
||||
self.assertEqual(nucleon["content"], "hello")
|
||||
self.assertEqual(nucleon["note"], "world")
|
||||
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
_ = nucleon["nonexistent"]
|
||||
|
||||
@@ -58,16 +60,23 @@ class TestNucleon(unittest.TestCase):
|
||||
|
||||
def test_do_eval_with_metadata_access(self):
|
||||
"""测试 do_eval 访问元数据"""
|
||||
nucleon = Nucleon("test_id", {"result": "eval:nucleon.metadata.get('value', 0)"}, {"value": 42})
|
||||
nucleon = Nucleon(
|
||||
"test_id",
|
||||
{"result": "eval:nucleon.metadata.get('value', 0)"},
|
||||
{"value": 42},
|
||||
)
|
||||
nucleon.do_eval()
|
||||
self.assertEqual(nucleon.payload["result"], "42")
|
||||
|
||||
def test_do_eval_nested(self):
|
||||
"""测试 do_eval 处理嵌套结构"""
|
||||
nucleon = Nucleon("test_id", {
|
||||
"list": ["eval:2*3", "normal"],
|
||||
"dict": {"key": "eval:'hello' + ' world'"}
|
||||
})
|
||||
nucleon = Nucleon(
|
||||
"test_id",
|
||||
{
|
||||
"list": ["eval:2*3", "normal"],
|
||||
"dict": {"key": "eval:'hello' + ' world'"},
|
||||
},
|
||||
)
|
||||
nucleon.do_eval()
|
||||
self.assertEqual(nucleon.payload["list"][0], "6")
|
||||
self.assertEqual(nucleon.payload["list"][1], "normal")
|
||||
@@ -95,5 +104,5 @@ class TestNucleon(unittest.TestCase):
|
||||
self.assertEqual(placeholder.metadata, {})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user