MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / test_goal_pickle_round_trip

Function test_goal_pickle_round_trip

tests/test_kernel_extra.py:116–132  ·  view source on GitHub ↗

Pickle a fresh GoalState to disk, reload it, and check that the round-tripped state still has the same shape (one open goal, not solved). The test takes some care to not exercise the GoalState lifecycle issue: it uses cheap field-projecting queries on each state, never the heavy Meta

(kernel)

Source from the content-addressed store, hash-verified

114
115
116def test_goal_pickle_round_trip(kernel):
117 """Pickle a fresh GoalState to disk, reload it, and check that the
118 round-tripped state still has the same shape (one open goal, not
119 solved). The test takes some care to not exercise the GoalState
120 lifecycle issue: it uses cheap field-projecting queries on each
121 state, never the heavy MetaM ops."""
122 state = kernel.goal_create("∀ n : Nat, n + 0 = n")
123 pre_n_goals = state.n_goals()
124 pre_solved = state.is_solved()
125 with tempfile.TemporaryDirectory() as d:
126 path = os.path.join(d, "goal.olean")
127 state.pickle(path)
128 assert os.path.getsize(path) > 0
129 # Round-trip
130 loaded = kernel.goal_unpickle(path)
131 assert loaded.n_goals() == pre_n_goals
132 assert loaded.is_solved() == pre_solved
133
134
135# ----------------------------------------------------------------------

Callers

nothing calls this directly

Calls 5

goal_createMethod · 0.80
n_goalsMethod · 0.80
is_solvedMethod · 0.80
pickleMethod · 0.80
goal_unpickleMethod · 0.80

Tested by

no test coverage detected