Pin the reload handoff under RELOAD_ names
This commit is contained in:
@@ -209,15 +209,15 @@ class Reload(unittest.TestCase):
|
||||
def test_runs_the_edited_file_before_trusting_it(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
script = os.path.join(root, "loop-claude")
|
||||
open(script, "w").write(loop.SOURCE.replace("import glob\n", "import glob\nimport no_such_module\n"))
|
||||
open(script, "w").write(loop.RELOAD_BASELINE.replace("import glob\n", "import glob\nimport no_such_module\n"))
|
||||
with unittest.mock.patch.object(loop, "__file__", script), unittest.mock.patch("os.execv") as execv:
|
||||
loop.reload_if_edited(cycle_number=1, failures=0)
|
||||
execv.assert_not_called()
|
||||
open(script, "w").write(loop.SOURCE.replace("CYCLE = ", "CYCLE = \"x\" or "))
|
||||
open(script, "w").write(loop.RELOAD_BASELINE.replace("RELOAD_CYCLE = ", "RELOAD_CYCLE = \"x\" or "))
|
||||
with unittest.mock.patch.object(loop, "__file__", script), unittest.mock.patch("os.execv") as execv:
|
||||
loop.reload_if_edited(cycle_number=1, failures=2)
|
||||
execv.assert_called_once()
|
||||
self.assertEqual((os.environ.pop(loop.CYCLE), os.environ.pop(loop.FAILURES)), ("1", "2"))
|
||||
self.assertEqual((os.environ.pop(loop.RELOAD_CYCLE), os.environ.pop(loop.RELOAD_FAILURES)), ("1", "2"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user