Files
AnyPS5/tools/tests/test_stubgen_stdout_newlines.py
T
thuanquangandClaude Opus 5.5 10fbc5b835 test(tools): simulate cp1252 and write LF fixtures on Python 3.9
On Python 3.9, Popen passes encoding=None, not "locale", to
TextIOWrapper, so simulated_cp1252 changed nothing and the encoding
regressions could not catch a missing encoding="utf-8". The stdout
newline test used Path.write_text(newline=...), which needs 3.10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 09:08:20 +07:00

34 lines
1000 B
Python

from pathlib import Path
import subprocess
import sys
import tempfile
import unittest
tools = Path(__file__).resolve().parents[1]
class StubgenStdoutNewlineTests(unittest.TestCase):
def run_stubgen(self, *extra):
with tempfile.TemporaryDirectory() as d:
nids = Path(d) / "nids.txt"
nids.write_bytes(b"AC1FtjqMCL0\n")
return subprocess.run(
[sys.executable, str(tools / "stubgen.py"), "--module", "libkernel", "--nids", str(nids)] + list(extra),
capture_output=True,
check=True,
)
def test_code_on_stdout_uses_lf(self):
result = self.run_stubgen()
self.assertIn(b"\n", result.stdout)
self.assertNotIn(b"\r\n", result.stdout)
def test_td_only_on_stdout_uses_lf(self):
result = self.run_stubgen("--td-only")
self.assertIn(b"\n", result.stdout)
self.assertNotIn(b"\r\n", result.stdout)
if __name__ == "__main__":
unittest.main()