diff options
| author | AAyberkU <97833630+AAyberkU@users.noreply.github.com> | 2026-11-22 21:47:34 +0300 |
|---|---|---|
| committer | AAyberkU <97833630+AAyberkU@users.noreply.github.com> | 2026-11-22 23:01:10 +0300 |
| commit | d7e2b00a3311b6718dc4d2d37aed548047150b29 (patch) | |
| tree | 60b2c08eb70fbbf336b163124121ab7c158da5ef /tests/test_tool_stdout_encoding.py | |
| parent | fb7b355e53c9776626350d02d65b69e93baeaa6a (diff) | |
test_tool_stdout_encoding: run the programs with -X utf8=0
Python 3.15 turns UTF-8 mode on by default, even under -I, so there a redirected stdout is UTF-8 and the
subprocess cases pass with or without the guard. -X utf8=0 keeps the code page they are about (review of
#2399 by nonverifiedperson). On 3.12 the flag changes nothing: 4 OK with the guard, 2 failures with
viewer/serve.py's taken out.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
Diffstat (limited to 'tests/test_tool_stdout_encoding.py')
| -rw-r--r-- | tests/test_tool_stdout_encoding.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/test_tool_stdout_encoding.py b/tests/test_tool_stdout_encoding.py index 65427b79e..d5333a7fb 100644 --- a/tests/test_tool_stdout_encoding.py +++ b/tests/test_tool_stdout_encoding.py | |||
| @@ -26,6 +26,9 @@ NOT_YET_GUARDED = { | |||
| 26 | "scripts/run_wine_tests.py", # open Wine runner pull requests change this file | 26 | "scripts/run_wine_tests.py", # open Wine runner pull requests change this file |
| 27 | } | 27 | } |
| 28 | MARK = "" | 28 | MARK = "" |
| 29 | # Python 3.15 turns UTF-8 mode on by default, even under -I, and then a redirected stdout cannot fail this way. | ||
| 30 | # -X utf8=0 keeps the code page these tests are about, so they still catch a missing guard there. | ||
| 31 | PYTHON = [sys.executable, "-I", "-X", "utf8=0"] | ||
| 29 | 32 | ||
| 30 | 33 | ||
| 31 | class EveryToolGuardsStdout(unittest.TestCase): | 34 | class EveryToolGuardsStdout(unittest.TestCase): |
| @@ -61,7 +64,7 @@ class MeasuredCrashes(unittest.TestCase): | |||
| 61 | for tool, with_out in self.CASES: | 64 | for tool, with_out in self.CASES: |
| 62 | with self.subTest(tool=tool): | 65 | with self.subTest(tool=tool): |
| 63 | argv = [src] + (["--out", out] if with_out else []) | 66 | argv = [src] + (["--out", out] if with_out else []) |
| 64 | r = subprocess.run([sys.executable, "-I", os.path.join(TOOLS, tool)] + argv, | 67 | r = subprocess.run(PYTHON + [os.path.join(TOOLS, tool)] + argv, |
| 65 | capture_output=True, cwd=ROOT, timeout=300) | 68 | capture_output=True, cwd=ROOT, timeout=300) |
| 66 | err = r.stderr.decode("utf-8", "replace") | 69 | err = r.stderr.decode("utf-8", "replace") |
| 67 | self.assertNotIn("UnicodeEncodeError", err) | 70 | self.assertNotIn("UnicodeEncodeError", err) |
| @@ -75,8 +78,9 @@ class ScriptsAndViewer(unittest.TestCase): | |||
| 75 | disasm = os.path.join(tmp, "disasm-" + MARK) | 78 | disasm = os.path.join(tmp, "disasm-" + MARK) |
| 76 | os.makedirs(disasm) | 79 | os.makedirs(disasm) |
| 77 | report = os.path.join(tmp, "rep-" + MARK + ".json") | 80 | report = os.path.join(tmp, "rep-" + MARK + ".json") |
| 78 | r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "scripts", "audit_shader4_regs.py"), | 81 | audit = os.path.join(ROOT, "scripts", "audit_shader4_regs.py") |
| 79 | disasm, "--json", report], capture_output=True, cwd=ROOT, timeout=300) | 82 | r = subprocess.run(PYTHON + [audit, disasm, "--json", report], |
| 83 | capture_output=True, cwd=ROOT, timeout=300) | ||
| 80 | err = r.stderr.decode("utf-8", "replace") | 84 | err = r.stderr.decode("utf-8", "replace") |
| 81 | self.assertNotIn("Traceback", err) | 85 | self.assertNotIn("Traceback", err) |
| 82 | self.assertEqual(r.returncode, 0, err) | 86 | self.assertEqual(r.returncode, 0, err) |
| @@ -87,8 +91,8 @@ class ScriptsAndViewer(unittest.TestCase): | |||
| 87 | with tempfile.TemporaryDirectory() as tmp: | 91 | with tempfile.TemporaryDirectory() as tmp: |
| 88 | world = os.path.join(tmp, "world-" + MARK) | 92 | world = os.path.join(tmp, "world-" + MARK) |
| 89 | os.makedirs(world) | 93 | os.makedirs(world) |
| 90 | proc = subprocess.Popen([sys.executable, "-I", os.path.join(ROOT, "viewer", "serve.py"), | 94 | serve = os.path.join(ROOT, "viewer", "serve.py") |
| 91 | "--world", world, "--port", "0"], | 95 | proc = subprocess.Popen(PYTHON + [serve, "--world", world, "--port", "0"], |
| 92 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ROOT) | 96 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ROOT) |
| 93 | try: | 97 | try: |
| 94 | line = proc.stdout.readline() # the viewer prints this line once it is listening | 98 | line = proc.stdout.readline() # the viewer prints this line once it is listening |