test: close unclosed file handles in tests (Path read/write)

Replace bare open().read()/write() in tests with Path.read_text/
write_text (or json.loads over read_text); the five remaining
open(...).close() empty-file creations become Path.write_text('').
No assertion, predicate, or production code changed; no behaviour
change beyond closing the handle deterministically.

Long-function splits and server.py module split intentionally not
included: the longest functions (_dispatch, _create_task,
_dispatch_project, ~375-395 lines in a 10430-line server.py) are
central routing/creation paths, and splitting them is not low-risk;
see PR body.
This commit is contained in:
openqj authored and host committed 2026-11-04 20:53:46 +00:00
1 parent fa4588a119
commit d779a1b426
9 files changed
+61 -57

No files matched your search

+2 -1
View File
@@ -10,6 +10,7 @@ import subprocess
import tarfile
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))))
@@ -59,7 +60,7 @@ class HostDeploySim(unittest.TestCase):
self.fake_bin = fake_bin
self.health_path = os.path.join(base, "health.json")
self.log_path = os.path.join(base, "systemctl.log")
open(self.log_path, "w").close()
Path(self.log_path).write_text("", encoding="utf-8")
self.env = dict(os.environ)
self.env["PATH"] = fake_bin + os.pathsep + os.environ["PATH"]
self.env["CODEX_DEPLOY_APP_DIR"] = self.app