fix(skills): make console diagnostics safe for cp1252

Fixes #292. Use readable ASCII status markers in 42 Python scripts across 20 skills, preserve figure and prompt text, keep copied validators/generators identical, and add static plus real-console regression coverage.

Validation: all 20 affected isolated skill suites and spec checks pass. PyMC required a process-local PYTENSOR_FLAGS=cxx=,linker=py,blas__ldflags= override because the native macOS linker could not find d64.
This commit is contained in:
Timothy Kassis committed 2026-09-30 16:45:48 -07:00
1 parent 351845e1c7
commit a0aea743b3
66 files changed
+516 -417

No files matched your search

+32
View File
@@ -12,6 +12,7 @@ in a temporary directory rather than mocking `open`.
from __future__ import annotations
import os
import subprocess
import sys
import tempfile
@@ -332,5 +333,36 @@ class FileValidationTests(unittest.TestCase):
self.assertEqual(messages, [])
class ConsoleEncodingTests(unittest.TestCase):
def run_legacy_console(self, script, *args, cwd=None):
return subprocess.run(
[sys.executable, str(SCRIPTS / script), *args],
env={**os.environ, "PYTHONIOENCODING": "cp1252"},
capture_output=True, text=True, encoding="cp1252", timeout=30, cwd=cwd,
)
def test_validation_success_and_failure_on_cp1252(self):
with tempfile.TemporaryDirectory() as directory:
bed = Path(directory) / "sample.bed"
bed.write_text("chr1\t10\t20\n", encoding="utf-8")
result = self.run_legacy_console("validate_files.py", "--bed", str(bed))
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("All validations passed", result.stdout)
result = self.run_legacy_console("validate_files.py", "--bam", str(bed) + ".missing")
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("Some validations failed", result.stdout)
self.assertNotIn("Traceback", result.stderr)
def test_workflow_generation_on_cp1252(self):
with tempfile.TemporaryDirectory() as directory:
result = self.run_legacy_console(
"workflow_generator.py", "chipseq_qc", "-o", "workflow.sh",
"--input-bam", "input.bam", "--chip-bams", "chip.bam", cwd=directory,
)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("Generated ChIP-seq QC workflow", result.stdout)
self.assertTrue((Path(directory) / "workflow.sh").is_file())
if __name__ == "__main__":
unittest.main()