Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Fixed
- **Tests on non-UTF-8 consoles (e.g. Korean Windows, cp949):** test subprocesses now
write and are read as UTF-8 (`tests/conftest.py` + `encoding="utf-8"`); 7 tests failed
there because the reader thread could not decode the CLI's emoji. Tests that pin a
console encoding still set it themselves. No package code changed.
- **Concurrent appenders no longer fork the chain.** `record()` and `witness_peer()`
(the two writers, both through `_seal`) now reads the head seal and writes
its line under an exclusive OS lock on a sidecar `<ledger>.lock` file. Before, two
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Make test subprocesses speak UTF-8 regardless of the host console.

Tests read child output with encoding="utf-8". On a non-UTF-8 Windows console
(e.g. Korean cp949) a child would otherwise print in the console codepage, and the
reader thread failed on emoji bytes, handing the test `stdout=None` (40 failures in
measure-mirror, 7 in action-mirror, 2026-11-24). Tests that pin a specific console
encoding set PYTHONIOENCODING themselves and still override this default.
"""
import os

os.environ.setdefault("PYTHONIOENCODING", "utf-8")
2 changes: 1 addition & 1 deletion tests/test_aat.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_verify_compares_timestamps_as_instants(tmp_path):

def _cli(*args):
return subprocess.run([sys.executable, "-m", "actmirror.am", *args],
capture_output=True, text=True, env=_ENV)
capture_output=True, encoding="utf-8", env=_ENV)


def test_cli_export_and_verify(tmp_path):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli_exit_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

def cli(*args):
return subprocess.run([sys.executable, "-m", "actmirror.am", *args],
capture_output=True, text=True, env=_ENV)
capture_output=True, encoding="utf-8", env=_ENV)


def _tamper_field(ledger: str, field: str, value):
Expand Down Expand Up @@ -122,7 +122,7 @@ def cli_in_encoding(encoding, *args, read_as=None):
thread died on byte 0x81 (the 👁 in the witness line) with stdout coming back None.
"""
env = {**_ENV, "PYTHONIOENCODING": encoding}
kw = {"encoding": read_as} if read_as else {"text": True}
kw = {"encoding": read_as or encoding}
return subprocess.run([sys.executable, "-m", "actmirror.am", *args],
capture_output=True, env=env, **kw)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_concurrent_append.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_concurrent_appenders_keep_one_chain(tmp_path):
env = dict(os.environ)
env["PYTHONPATH"] = ROOT + os.pathsep + env.get("PYTHONPATH", "")
procs = [subprocess.Popen([sys.executable, "-c", WRITER, path, str(w), "30"],
env=env, stderr=subprocess.PIPE, text=True)
env=env, stderr=subprocess.PIPE, encoding="utf-8")
for w in range(4)]
for p in procs:
_, err = p.communicate(timeout=120)
Expand Down
Loading