Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

test: read a child command's output as UTF-8, the CLI's byte contract

Soohong Kim930960b7e44c
diff --git a/tests/background/test_tile_cli.py b/tests/background/test_tile_cli.py
index 3247796..94ce76d 100644
--- a/tests/background/test_tile_cli.py
+++ b/tests/background/test_tile_cli.py
@@ -18,7 +18,7 @@ def invoke(source, out, *extra):
return subprocess.run(
[sys.executable, "-m", "sprite_gen.background.tile", "--source", str(source),
"--out", str(out), "--period", "8", "--overlap", "3", *map(str, extra)],
- capture_output=True, text=True, timeout=20,
+ capture_output=True, encoding="utf-8", timeout=20,
)
diff --git a/tests/compose/test_export_aseprite.py b/tests/compose/test_export_aseprite.py
index e36f557..efa99fd 100644
--- a/tests/compose/test_export_aseprite.py
+++ b/tests/compose/test_export_aseprite.py
@@ -78,7 +78,7 @@ def test_real_composed_run_exports_phaser_and_flame_shapes(fixture_run_dir: Path
assert compose.returncode == 0, compose.stdout + compose.stderr
command = [sys.executable, "-m", "sprite_gen.cli", "export-aseprite", "--run-dir", str(fixture_run_dir)]
- result = subprocess.run(command, cwd=ROOT, capture_output=True, text=True)
+ result = subprocess.run(command, cwd=ROOT, capture_output=True, encoding="utf-8")
assert result.returncode == 0, result.stdout + result.stderr
exported = json.loads((fixture_run_dir / "exports" / "aseprite.json").read_text(encoding="utf-8"))
manifest = json.loads((fixture_run_dir / "manifest.json").read_text(encoding="utf-8"))
@@ -88,7 +88,7 @@ def test_real_composed_run_exports_phaser_and_flame_shapes(fixture_run_dir: Path
}
assert (fixture_run_dir / exported["meta"]["image"]).is_file()
- result = subprocess.run(command + ["--format", "json-hash", "--split-states"], cwd=ROOT, capture_output=True, text=True)
+ result = subprocess.run(command + ["--format", "json-hash", "--split-states"], cwd=ROOT, capture_output=True, encoding="utf-8")
assert result.returncode == 0, result.stdout + result.stderr
for state, rects in manifest["frame_layout"]["rows"].items():
document = json.loads((fixture_run_dir / "exports" / "aseprite" / f"{state}.json").read_text(encoding="utf-8"))
diff --git a/tests/compose/test_game_pack.py b/tests/compose/test_game_pack.py
index e297673..29635a0 100644
--- a/tests/compose/test_game_pack.py
+++ b/tests/compose/test_game_pack.py
@@ -215,7 +215,7 @@ def test_cli_dispatch_and_real_files(tmp_path):
strip(tmp_path)
src = request(tmp_path, [{"id": "walk", "source": "walk.strip.json", "display": {"height": 10}}])
call = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "game-pack", "--request", str(src),
- "--out-dir", str(tmp_path / "out")], capture_output=True, text=True)
+ "--out-dir", str(tmp_path / "out")], capture_output=True, encoding="utf-8")
assert call.returncode == 0, call.stderr
assert json.loads(call.stdout)["ok"] is True
assert (tmp_path / "out" / "game-pack.json").is_file()
diff --git a/tests/conftest.py b/tests/conftest.py
index 0fe3efe..ed57a20 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -26,7 +26,7 @@ def help_options(*argv: str) -> set[str]:
[sys.executable, *argv, "--help"],
cwd=REPO_ROOT,
capture_output=True,
- text=True,
+ encoding="utf-8",
env=env,
)
assert proc.returncode == 0, proc.stderr
@@ -38,7 +38,7 @@ def run_script(name: str, *args: str) -> subprocess.CompletedProcess[str]:
return subprocess.run(
[sys.executable, str(SCRIPTS_DIR / name), *args],
capture_output=True,
- text=True,
+ encoding="utf-8",
)
diff --git a/tests/curate/test_anchor_selection.py b/tests/curate/test_anchor_selection.py
index 532f229..5027a1d 100644
--- a/tests/curate/test_anchor_selection.py
+++ b/tests/curate/test_anchor_selection.py
@@ -229,7 +229,7 @@ def _cli(run_dir: Path, *args: str):
return subprocess.run([sys.executable, "-m", "sprite_gen.cli", "anchor",
"--run-dir", str(run_dir), *args],
- capture_output=True, text=True, cwd=str(ROOT))
+ capture_output=True, encoding="utf-8", cwd=str(ROOT))
def test_cli_pending_failure_prints_the_guidance(ungenerated_run: Path) -> None:
diff --git a/tests/effects/test_breathe_js_mirror.py b/tests/effects/test_breathe_js_mirror.py
index 294ca90..4552757 100644
--- a/tests/effects/test_breathe_js_mirror.py
+++ b/tests/effects/test_breathe_js_mirror.py
@@ -119,7 +119,7 @@ def test_curator_mirror_is_byte_identical_to_the_bake(build, overrides, tmp_path
harness.write_text(HARNESS, encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(harness), str(payload_path)],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
js_frames = json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))
@@ -162,7 +162,7 @@ def test_the_mirror_refuses_exactly_what_the_bake_refuses(tmp_path):
(tmp_path / "payload.json").write_text(json.dumps(payload), encoding="utf-8")
(tmp_path / "harness.cjs").write_text(HARNESS, encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(tmp_path / "harness.cjs"),
- str(tmp_path / "payload.json")], capture_output=True, text=True)
+ str(tmp_path / "payload.json")], capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
js = json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))
@@ -216,7 +216,7 @@ def test_the_mirror_matches_on_frames_other_than_the_frozen_one(tmp_path):
(tmp_path / "payload.json").write_text(json.dumps(payload), encoding="utf-8")
(tmp_path / "harness.cjs").write_text(HARNESS, encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(tmp_path / "harness.cjs"),
- str(tmp_path / "payload.json")], capture_output=True, text=True)
+ str(tmp_path / "payload.json")], capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
js = json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))
@@ -262,7 +262,7 @@ def test_the_mirror_refuses_the_same_strain_cap(tmp_path):
(tmp_path / "payload.json").write_text(json.dumps(payload), encoding="utf-8")
(tmp_path / "harness.cjs").write_text(HARNESS, encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(tmp_path / "harness.cjs"),
- str(tmp_path / "payload.json")], capture_output=True, text=True)
+ str(tmp_path / "payload.json")], capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
got = json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))[0]
assert not got["ok"] and got["refused"], \
@@ -297,7 +297,7 @@ def test_the_mirror_refuses_a_stale_anatomy_against_a_manual_rigid_row(tmp_path)
(tmp_path / "payload.json").write_text(json.dumps(payload), encoding="utf-8")
(tmp_path / "harness.cjs").write_text(HARNESS, encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(tmp_path / "harness.cjs"),
- str(tmp_path / "payload.json")], capture_output=True, text=True)
+ str(tmp_path / "payload.json")], capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
for phase, got in zip(PHASES, json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))):
assert not got["ok"] and got["refused"], (
@@ -310,7 +310,7 @@ def test_the_mirror_refuses_a_stale_anatomy_against_a_manual_rigid_row(tmp_path)
"rigid_row": override, "anatomy": fresh["anatomy"]}
(tmp_path / "payload.json").write_text(json.dumps(payload), encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(tmp_path / "harness.cjs"),
- str(tmp_path / "payload.json")], capture_output=True, text=True)
+ str(tmp_path / "payload.json")], capture_output=True, encoding="utf-8")
assert proc.returncode == 0
for phase, got in zip(PHASES, json.loads((tmp_path / "js.json").read_text(encoding="utf-8"))):
assert got["ok"], f"갱신 후에도 거부한다: {got['message']}"
@@ -365,7 +365,7 @@ def test_the_mirror_refuses_a_stale_reference_frame(tmp_path):
"anatomy": cfg["anatomy"]},
"out": str(tmp_path / "out.json")}), encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(harness), str(CURATOR_BREATHE), str(src_json)],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
got = json.loads((tmp_path / "out.json").read_text(encoding="utf-8"))
assert not got["ok"] and got["refused"], (
@@ -379,7 +379,7 @@ def test_the_mirror_refuses_a_stale_reference_frame(tmp_path):
"anatomy": cfg["anatomy"]},
"out": str(tmp_path / "out.json")}), encoding="utf-8")
subprocess.run([shutil.which("node"), str(harness), str(CURATOR_BREATHE), str(src_json)],
- capture_output=True, text=True, check=True)
+ capture_output=True, encoding="utf-8", check=True)
assert json.loads((tmp_path / "out.json").read_text(encoding="utf-8"))["ok"], \
"기준 프레임 그대로인데 거부한다 — 프리뷰가 상시 죽는다"
@@ -424,7 +424,7 @@ def test_the_mirror_refuses_when_it_cannot_verify(tmp_path):
"anatomy": frozen},
"out": str(tmp_path / "out.json")}), encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(harness), str(CURATOR_BREATHE), str(src_json)],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
got = json.loads((tmp_path / "out.json").read_text(encoding="utf-8"))
assert not got["ok"] and got["refused"], (
diff --git a/tests/effects/test_breathe_reference_key.py b/tests/effects/test_breathe_reference_key.py
index 2ce5dea..24f6c33 100644
--- a/tests/effects/test_breathe_reference_key.py
+++ b/tests/effects/test_breathe_reference_key.py
@@ -41,7 +41,7 @@ def _node(script: str, payload: dict):
pj = Path(tmp) / "payload.json"
pj.write_text(json.dumps(payload), encoding="utf-8")
run = subprocess.run(["node", "-e", script, str(pj)],
- capture_output=True, text=True, timeout=120)
+ capture_output=True, encoding="utf-8", timeout=120)
assert run.returncode == 0, f"node 실패:\n{run.stderr}"
return json.loads(run.stdout)
diff --git a/tests/effects/test_breathe_sidecar_roundtrip.py b/tests/effects/test_breathe_sidecar_roundtrip.py
index dddbc9a..5be7c7e 100644
--- a/tests/effects/test_breathe_sidecar_roundtrip.py
+++ b/tests/effects/test_breathe_sidecar_roundtrip.py
@@ -79,7 +79,7 @@ def _run(payload, tmp_path):
src = tmp_path / "in.json"
src.write_text(json.dumps(payload), encoding="utf-8")
proc = subprocess.run([shutil.which("node"), str(harness), str(CURATOR), str(src)],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"node 하네스 실패:\n{proc.stderr}"
return json.loads(Path(payload["out"]).read_text(encoding="utf-8"))
diff --git a/tests/effects/test_shadow.py b/tests/effects/test_shadow.py
index 7330c52..bcbb249 100644
--- a/tests/effects/test_shadow.py
+++ b/tests/effects/test_shadow.py
@@ -378,7 +378,7 @@ def test_module_cli_executes_the_real_publication_path(tmp_path):
result = subprocess.run(
[sys.executable, "-m", "sprite_gen.effects.shadow", "--source", str(source),
"--out-dir", str(out_dir), "--shear", "-0.8", "--color", "10,20,30"],
- capture_output=True, text=True, check=False,
+ capture_output=True, encoding="utf-8", check=False,
)
assert result.returncode == 0, result.stderr
report = json.loads(result.stdout)
diff --git a/tests/gen/test_body_plan_sheets.py b/tests/gen/test_body_plan_sheets.py
index 6bb5c57..0673795 100644
--- a/tests/gen/test_body_plan_sheets.py
+++ b/tests/gen/test_body_plan_sheets.py
@@ -121,7 +121,7 @@ def test_a_horse_walk_row_and_wave(rows) -> None:
def _prepare_cli(*args: str) -> subprocess.CompletedProcess:
- return subprocess.run([sys.executable, "-m", "sprite_gen.cli", "prepare", *args], text=True, capture_output=True)
+ return subprocess.run([sys.executable, "-m", "sprite_gen.cli", "prepare", *args], encoding="utf-8", capture_output=True)
def test_the_sheet_cli_takes_records_and_carries_the_body_plan(tmp_path) -> None:
diff --git a/tests/gen/test_codex_unavailable.py b/tests/gen/test_codex_unavailable.py
index 0490262..bcfdb15 100644
--- a/tests/gen/test_codex_unavailable.py
+++ b/tests/gen/test_codex_unavailable.py
@@ -49,7 +49,7 @@ NOT_SIGNED_IN = "codex not logged in (codex login status exit 1)"
def _cli(*args: str, env: dict[str, str] | None = None) -> subprocess.CompletedProcess[str]:
- return subprocess.run([sys.executable, "-m", "sprite_gen.cli", *args], capture_output=True, text=True,
+ return subprocess.run([sys.executable, "-m", "sprite_gen.cli", *args], capture_output=True, encoding="utf-8",
encoding="utf-8", env=env, cwd=REPO_ROOT)
diff --git a/tests/packaging/test_cli_taxonomy.py b/tests/packaging/test_cli_taxonomy.py
index f87906e..6fcd2ce 100644
--- a/tests/packaging/test_cli_taxonomy.py
+++ b/tests/packaging/test_cli_taxonomy.py
@@ -33,7 +33,7 @@ def test_domain_of_refuses_unknown_modules() -> None:
def test_help_lists_each_verb_once_under_its_domain() -> None:
- proc = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "--help"], capture_output=True, text=True)
+ proc = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "--help"], capture_output=True, encoding="utf-8")
assert proc.returncode == 0, proc.stderr
out = proc.stdout
for domain, verbs in cli.command_domains().items():
diff --git a/tests/packaging/test_curation_asset_packaging.py b/tests/packaging/test_curation_asset_packaging.py
index d57ea6c..a80379a 100644
--- a/tests/packaging/test_curation_asset_packaging.py
+++ b/tests/packaging/test_curation_asset_packaging.py
@@ -71,7 +71,7 @@ def wheel_names(tmp_path_factory: pytest.TempPathFactory) -> set[str]:
ignore=shutil.ignore_patterns("__pycache__"))
out = tmp_path_factory.mktemp("wheel")
built_by = subprocess.run([sys.executable, "-c", _BUILD_WHEEL, str(out)],
- cwd=project, capture_output=True, text=True)
+ cwd=project, capture_output=True, encoding="utf-8")
assert built_by.returncode == 0, (
f"the declared build backend could not build this project:\n{built_by.stderr}")
built = list(out.glob("*.whl"))
diff --git a/tests/packaging/test_numpy_dependency_gate.py b/tests/packaging/test_numpy_dependency_gate.py
index 7b1c079..1638261 100644
--- a/tests/packaging/test_numpy_dependency_gate.py
+++ b/tests/packaging/test_numpy_dependency_gate.py
@@ -157,7 +157,7 @@ def _run(args: list[str], *, numpy_blocked: bool, tmp_path: Path) -> subprocess.
env["PYTHONPATH"] = os.pathsep.join(
[str(tmp_path), env.get("PYTHONPATH", "")]).rstrip(os.pathsep)
return subprocess.run(
- [sys.executable, *args], cwd=ROOT, env=env, capture_output=True, text=True, timeout=180)
+ [sys.executable, *args], cwd=ROOT, env=env, capture_output=True, encoding="utf-8", timeout=180)
def test_the_scanned_entrypoints_are_the_real_ones() -> None:
diff --git a/tests/packaging/test_package_surface.py b/tests/packaging/test_package_surface.py
index 46fe233..7263c05 100644
--- a/tests/packaging/test_package_surface.py
+++ b/tests/packaging/test_package_surface.py
@@ -152,7 +152,7 @@ def test_scripts_wrappers_reexport_their_package_module() -> None:
f"m = runpy.run_path({str(ROOT / 'scripts' / 'serve_curation.py')!r});"
"sys.exit(0 if callable(m.get('main')) and callable(m.get('build_run_state')) else 1)"
)
- proc = subprocess.run([sys.executable, "-c", probe], cwd=ROOT, capture_output=True, text=True)
+ proc = subprocess.run([sys.executable, "-c", probe], cwd=ROOT, capture_output=True, encoding="utf-8")
assert proc.returncode == 0, f"scripts/serve_curation.py stopped re-exporting the impl:\n{proc.stderr}"
# That the wrapper also runs the entrypoint (`python scripts/serve_curation.py` is a
diff --git a/tests/qa/test_handed_check.py b/tests/qa/test_handed_check.py
index 7c2d84f..00a576c 100644
--- a/tests/qa/test_handed_check.py
+++ b/tests/qa/test_handed_check.py
@@ -204,11 +204,11 @@ def test_cli_reads_a_strip_writes_a_board_and_exits_on_a_mirror(tmp_path) -> Non
base = [sys.executable, "-m", "sprite_gen.cli", "handed-check", "--direction", "front_diagonal", "--facing", "left",
"--handed", "the black smartwatch=left wrist", "--marker", "#1e5aeb"]
ok = subprocess.run([*base, "--strip", str(good), "--board", str(tmp_path / "ok.png"),
- "--report", str(tmp_path / "ok.json")], capture_output=True, text=True)
+ "--report", str(tmp_path / "ok.json")], capture_output=True, encoding="utf-8")
assert ok.returncode == 0, ok.stderr
assert json.loads(ok.stdout)["ok"] and (tmp_path / "ok.png").is_file()
assert json.loads((tmp_path / "ok.json").read_text())["frames"] == 6
- no = subprocess.run([*base, "--strip", str(bad)], capture_output=True, text=True)
+ no = subprocess.run([*base, "--strip", str(bad)], capture_output=True, encoding="utf-8")
assert no.returncode == 1 and "on the picture's left, expected its right" in no.stderr
diff --git a/tests/qa/test_motion.py b/tests/qa/test_motion.py
index 3dd7822..eda7b14 100644
--- a/tests/qa/test_motion.py
+++ b/tests/qa/test_motion.py
@@ -235,7 +235,7 @@ def test_module_entrypoint_publishes_report_and_preserves_sources(tmp_path):
[sys.executable, "-m", "sprite_gen.qa.motion", "--source", str(source),
"--contacts", "0:4", "--foot-box", "8,25,34,12", "--fps", "5",
"--facing", "right", "--out", str(output)],
- capture_output=True, text=True, check=False,
+ capture_output=True, encoding="utf-8", check=False,
)
assert result.returncode == 0, result.stderr
report = json.loads(output.read_text())
diff --git a/tests/release/test_lane_rife_collection.py b/tests/release/test_lane_rife_collection.py
index 434e337..be1b99f 100644
--- a/tests/release/test_lane_rife_collection.py
+++ b/tests/release/test_lane_rife_collection.py
@@ -82,7 +82,7 @@ def _collect(tmp_path: Path, name: str, env: dict[str, str]) -> dict[str, list[b
cwd=ROOT,
env={**env, "RIFE_PROBE_OUT": str(out)},
capture_output=True,
- text=True,
+ encoding="utf-8",
)
assert proc.returncode == 0, f"collection with {name} failed:\n{proc.stdout[-3000:]}\n{proc.stderr[-3000:]}"
return json.loads(out.read_text())
@@ -184,7 +184,7 @@ def test_the_rife_less_run_fails_each_unmarked_skip_by_name(tmp_path):
cwd=ROOT,
env=_rife_less_env(tmp_path),
capture_output=True,
- text=True,
+ encoding="utf-8",
)
output = f"{proc.stdout[-3000:]}\n{proc.stderr[-3000:]}"
assert report.is_file(), output
diff --git a/tests/release/test_release_notes.py b/tests/release/test_release_notes.py
index e682992..35908ca 100644
--- a/tests/release/test_release_notes.py
+++ b/tests/release/test_release_notes.py
@@ -208,7 +208,7 @@ def test_the_anchor_matches_githubs_slug_rules() -> None:
def _cli(*args: str) -> subprocess.CompletedProcess[str]:
return subprocess.run([sys.executable, str(ROOT / "scripts" / "release_notes.py"), *args],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
def test_the_cli_writes_title_body_and_assets(tmp_path: Path) -> None:
diff --git a/tests/release/test_release_publish.py b/tests/release/test_release_publish.py
index 021a128..b6f6157 100644
--- a/tests/release/test_release_publish.py
+++ b/tests/release/test_release_publish.py
@@ -78,7 +78,7 @@ class Harness:
return subprocess.run(
[sys.executable, str(PUBLISH), "--tag", "v1.3.0", "--repo", "example/example",
"--checkout", str(self.checkout), "--gh", str(self.gh), "--skip-build", *args],
- capture_output=True, text=True, env=env)
+ capture_output=True, encoding="utf-8", env=env)
@property
def calls(self) -> list[str]:
@@ -150,7 +150,7 @@ def test_a_dist_directory_with_stale_archives_is_refused(harness: Harness, tmp_p
proc = subprocess.run(
[sys.executable, str(PUBLISH), "--tag", "v1.3.0", "--repo", "example/example",
"--checkout", str(harness.checkout), "--gh", str(harness.gh), "--dist-dir", str(stale)],
- capture_output=True, text=True,
+ capture_output=True, encoding="utf-8",
env={**os.environ, "GH_STUB_STATE": str(harness.state), "GH_STUB_LOG": str(harness.log)})
assert proc.returncode == 2
assert "not empty" in proc.stderr
@@ -160,7 +160,7 @@ def test_a_dist_directory_with_stale_archives_is_refused(harness: Harness, tmp_p
def _git(cwd: Path, *args: str) -> str:
return subprocess.run(
["git", "-c", "user.name=t", "-c", "[email protected]", *args],
- cwd=cwd, check=True, capture_output=True, text=True).stdout.strip()
+ cwd=cwd, check=True, capture_output=True, encoding="utf-8").stdout.strip()
def _tagged(harness: Harness) -> str:
@@ -192,7 +192,7 @@ def _run_prebuilt(harness: Harness, prebuilt: Path, *args: str) -> subprocess.Co
[sys.executable, str(PUBLISH), "--tag", "v1.3.0", "--repo", "example/example",
"--checkout", str(harness.checkout), "--gh", str(harness.gh), "--prebuilt", str(prebuilt),
*args],
- capture_output=True, text=True,
+ capture_output=True, encoding="utf-8",
env={**os.environ, "GH_STUB_STATE": str(harness.state), "GH_STUB_LOG": str(harness.log)})
diff --git a/tests/scene/test_inspect_scene.py b/tests/scene/test_inspect_scene.py
index 6d5a857..bd7c7e0 100644
--- a/tests/scene/test_inspect_scene.py
+++ b/tests/scene/test_inspect_scene.py
@@ -214,7 +214,7 @@ def test_module_entrypoint_reports_and_signals_a_failed_loop(tmp_path):
spec = ramp_scene(tmp_path)
out = tmp_path / "inspection.json"
result = subprocess.run([sys.executable, "-m", "sprite_gen.scene.inspect_scene", "--spec", str(spec), "--out", str(out), "--require-loop"],
- capture_output=True, text=True, check=False)
+ capture_output=True, encoding="utf-8", check=False)
assert result.returncode == 1, result.stderr
report = json.loads(result.stdout)
assert report == json.loads(out.read_text())
diff --git a/tests/scene/test_render.py b/tests/scene/test_render.py
index 2b86936..45ea0d7 100644
--- a/tests/scene/test_render.py
+++ b/tests/scene/test_render.py
@@ -308,11 +308,11 @@ def test_module_entrypoint_renders_and_reports_failures_by_name(tmp_path):
spec = write_scene(tmp_path, [{"id": "hero", "asset": "red", "at": [8, 12]}], width=15)
out = tmp_path / "out"
result = subprocess.run([sys.executable, "-m", "sprite_gen.scene.render", "--spec", str(spec), "--out-dir", str(out), "--formats", "png"],
- capture_output=True, text=True, check=False)
+ capture_output=True, encoding="utf-8", check=False)
assert result.returncode == 0, result.stderr
summary = json.loads(result.stdout)
assert summary["frames"] == 5 and summary["inspection_status"] == "measured" and "placement.json" in summary["files"]
failed = subprocess.run([sys.executable, "-m", "sprite_gen.scene.render", "--spec", str(spec), "--out-dir", str(tmp_path / "video"), "--formats", "mp4"],
- capture_output=True, text=True, check=False)
+ capture_output=True, encoding="utf-8", check=False)
assert failed.returncode != 0 and "scene-render: MP4 requires even canvas dimensions" in failed.stderr
assert not (tmp_path / "video").exists()
diff --git a/tests/serve/test_curation_view_contract.py b/tests/serve/test_curation_view_contract.py
index 895751c..b7c296b 100644
--- a/tests/serve/test_curation_view_contract.py
+++ b/tests/serve/test_curation_view_contract.py
@@ -135,7 +135,7 @@ def _run_import(pngs: Path, out: Path, *extra: str) -> subprocess.CompletedProce
return subprocess.run(
[sys.executable, str(ROOT / "scripts" / "unpack_atlas_run.py"),
"--pngs-dir", str(pngs), "--out-dir", str(out), *extra],
- capture_output=True, text=True,
+ capture_output=True, encoding="utf-8",
)
diff --git a/tests/serve/test_curator_single_display_pipeline.py b/tests/serve/test_curator_single_display_pipeline.py
index e021e2b..cc8e879 100644
--- a/tests/serve/test_curator_single_display_pipeline.py
+++ b/tests/serve/test_curator_single_display_pipeline.py
@@ -129,7 +129,7 @@ def test_server_snapshot_grid_behavior(tmp_path):
r = subprocess.run(
[sys.executable, str(ROOT / "scripts" / "unpack_atlas_run.py"),
"--pngs-dir", str(tmp_path / "pngs"), "--out-dir", str(out), "--force"],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert r.returncode == 0, r.stderr
import sprite_gen.serve.serve_curation as serve_curation
snap = serve_curation.build_run_state(out)
diff --git a/tests/spec/test_publish_rwlock_cross_process.py b/tests/spec/test_publish_rwlock_cross_process.py
index 91e628e..80ffecc 100644
--- a/tests/spec/test_publish_rwlock_cross_process.py
+++ b/tests/spec/test_publish_rwlock_cross_process.py
@@ -36,7 +36,7 @@ class ChildGuard:
[sys.executable, "-c", _CHILD, str(run_dir), mode, str(hold)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- text=True,
+ encoding="utf-8",
encoding="utf-8",
)
self.thread = threading.Thread(target=self._drain, daemon=True)
diff --git a/tests/util/test_console.py b/tests/util/test_console.py
index 4947df8..65b42fd 100644
--- a/tests/util/test_console.py
+++ b/tests/util/test_console.py
@@ -12,8 +12,6 @@ import sys
import pytest
from PIL import Image
-from sprite_gen.util import console
-
ROOT = Path(__file__).resolve().parents[2]
@@ -32,6 +30,8 @@ def test_a_command_on_a_cp949_stream_prints_its_em_dash_as_utf8(tmp_path, entry)
def test_only_a_stream_that_is_not_utf8_is_reopened(monkeypatch):
+ from sprite_gen.util import console
+
legacy = io.TextIOWrapper(io.BytesIO(), encoding="cp949")
already = io.TextIOWrapper(io.BytesIO(), encoding="UTF8", errors="surrogateescape")
monkeypatch.setattr(sys, "stdout", legacy)
diff --git a/tests/video/test_clip_prompt.py b/tests/video/test_clip_prompt.py
index 1d407dc..bb1a1e2 100644
--- a/tests/video/test_clip_prompt.py
+++ b/tests/video/test_clip_prompt.py
@@ -128,12 +128,12 @@ def test_a_front_walk_carries_its_mid_step_redraw() -> None:
def test_the_cli_prints_the_prompt_alone_or_the_record() -> None:
args = [sys.executable, "-m", "sprite_gen.cli", "video-prompt", "--direction", "side", "--state", "walk", "--no-last-frame"]
- plain = subprocess.run(args, capture_output=True, text=True)
+ plain = subprocess.run(args, capture_output=True, encoding="utf-8")
assert plain.returncode == 0, plain.stderr
assert plain.stdout.strip() == batch_mod.build_prompt("side", "walk", None, model=clip_prompt.DEFAULT_MODEL)
- record = json.loads(subprocess.run([*args, "--json"], capture_output=True, text=True, check=True).stdout)
+ record = json.loads(subprocess.run([*args, "--json"], capture_output=True, encoding="utf-8", check=True).stdout)
assert record["kind"] == "sprite-gen-video-prompt" and record["state"] == "walk"
- refused = subprocess.run([*args[:-3], "attack", "--no-last-frame"], capture_output=True, text=True)
+ refused = subprocess.run([*args[:-3], "attack", "--no-last-frame"], capture_output=True, encoding="utf-8")
assert refused.returncode != 0 and "--unpinned" in refused.stderr and not refused.stdout
diff --git a/tests/video/test_play.py b/tests/video/test_play.py
index aad4892..c4eafbc 100644
--- a/tests/video/test_play.py
+++ b/tests/video/test_play.py
@@ -275,11 +275,11 @@ def test_a_once_return_cut_keeps_both_ends_and_plays_once(tmp_path) -> None:
def test_the_clis_take_the_play_mode(tmp_path) -> None:
out = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "video-prompt", "--direction", "side", "--state", "punch",
- "--play", "once-return", "--motion", PUNCH, "--json"], capture_output=True, text=True)
+ "--play", "once-return", "--motion", PUNCH, "--json"], capture_output=True, encoding="utf-8")
assert out.returncode == 0, out.stderr
record = json.loads(out.stdout)
assert record["play"] == "once-return" and record["cycle"] == "once-return" and PUNCH in record["prompt"]
refused = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "video-set", "--base", f"side={still(tmp_path / 's.png')}",
"--states", "death", "--play", "death=loop", "--out-dir", str(tmp_path / "set")],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert refused.returncode != 0 and "death plays once-hold only" in refused.stderr
diff --git a/tests/workflow/test_workflow.py b/tests/workflow/test_workflow.py
index c64d418..ec41ca9 100644
--- a/tests/workflow/test_workflow.py
+++ b/tests/workflow/test_workflow.py
@@ -196,7 +196,7 @@ def test_video_api_key_requires_own_confirmation(monkeypatch, tmp_path):
def test_real_cli_finish_save_and_reload(tmp_path):
def cli(*args):
- p = subprocess.run([sys.executable, "-m", "sprite_gen.cli", *args], capture_output=True, text=True)
+ p = subprocess.run([sys.executable, "-m", "sprite_gen.cli", *args], capture_output=True, encoding="utf-8")
return p, json.loads(p.stdout) if p.stdout else None
p, data = cli("defaults", "show")
assert p.returncode == 0 and data["revision"] == "missing"
@@ -233,7 +233,7 @@ def test_one_image_can_enter_optional_curation(tmp_path, ready_login):
run = tmp_path / "curation-run"
imported = subprocess.run([sys.executable, "-m", "sprite_gen.cli", "unpack-atlas",
"--pngs-dir", str(pngs), "--out-dir", str(run)],
- capture_output=True, text=True)
+ capture_output=True, encoding="utf-8")
assert imported.returncode == 0, imported.stderr
state = build_run_state(run)
assert sum(len(row["frames"]) for row in state["states"]) == 1