Resolve decode_state's field types from string annotations too
This commit was merged in pull request #122.
This commit is contained in:
+10
-1
@@ -1,3 +1,4 @@
|
||||
import dataclasses
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
@@ -7,7 +8,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from loop_claude import file_writes, main
|
||||
from loop_claude import file_writes, main, reload
|
||||
from loop_claude.claude_code import formats, transcript
|
||||
from loop_claude.claude_runs import judge
|
||||
from loop_claude.outcome import Failure, Stop
|
||||
@@ -119,6 +120,14 @@ class LoopState(unittest.TestCase):
|
||||
with self.subTest(handed=handed):
|
||||
self.assertEqual(main.loop_state([main.RELOAD_FLAG, *handed], CWD), Stop(1, f"the reload cannot read the loop's state from {handed}; rerun loop-claude <task>"))
|
||||
|
||||
def test_decodes_a_state_whose_annotations_are_strings(self):
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Stringly:
|
||||
count: "int"
|
||||
name: "str"
|
||||
self.assertEqual(reload.decode_state('{"count": 1, "name": "n"}', Stringly), Stringly(1, "n"))
|
||||
self.assertIsNone(reload.decode_state('{"count": "1", "name": "n"}', Stringly))
|
||||
|
||||
|
||||
|
||||
class ReplaceFile(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user