diff --git "a/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" "b/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" index d0254bf..8843ca0 100644 --- "a/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" +++ "b/docs/03_PLAN/PLAN_02_\351\226\213\347\231\272\343\202\271\343\203\206\343\203\203\343\203\227.md" @@ -47,6 +47,7 @@ | 1-7 | 表示・help の使用例・コメントに,TongueSegModel の言葉(「学習データのバンドル」,`tsm-train`・`tsm-export`,`TIAS_DATA_ROOT` の経緯)が残っている.テストの名前にも `tsm` が残っている(`test_markers_use_tsm_prefix`・`TestRunIdOfTsmTrain`) | | 1-7 | コメント・docstring の SPEC の参照(約 36 行)は,移す元の文書を指している.該当のコードを書き換えるステップで,LabRemote の SPEC を指す形に直す | | 1-2 以降 | `cli.py` は約 1200 行あり,GPU の選択の流れ・git の状態の取得・tar の受け取りを抱えている.設定に出すときに,判定を各モジュールへ分ける(`.claude/rules/project-structure.md`) | +| 1-7 | コンソールの文字コードが日本語を表せない環境(CI の Windows は cp1252)では,help や表示の書き出しで `UnicodeEncodeError` になり,コマンドが落ちる.手元(cp932)とサーバ(UTF-8)では起きない.入口で「表せない文字は置き換えて出す」設定にする.今は `test_imports.py` の `test_help_runs_without_torch` が,子プロセスに UTF-8 を指定して避けている | | M2 | `test_cli.py` の `test_subcommands_listed_in_help_are_from_spec` は,help の字下げの幅に頼って一覧を読んでいる.`ls`・`clean` を足すときに壊れやすい | - **TongueSegModel のテストに,実際のアドレスとユーザー名が残っている**(`tests/remote/` の `test_commands.py`・`test_config.py`・`test_gpu.py`・`test_report.py`,`tests/cli/test_remote.py`,`remote/report.py` の docstring).LabRemote には持ち込まず,文書用のアドレスと架空の名前に置き換えた.TongueSegModel の側は,3-4 でこれらのファイルを消すときに無くなる diff --git a/tests/test_imports.py b/tests/test_imports.py index b4074a0..bf9f674 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -11,6 +11,7 @@ from __future__ import annotations import json +import os import subprocess import sys @@ -71,8 +72,17 @@ "assert 'torch' not in sys.modules\n" "print('ok')\n" ) + # help は日本語を含む.子プロセスの出力はパイプになり,文字コードが日本語を表せない環境 + # (CI の Windows は cp1252)では書き出しで落ちるため,UTF-8 を指定して起動する. + # 指定が無いとコマンド自体が落ちる点は,PLAN_02「1-1 で分かったこと」で 1-7 に回してある result = subprocess.run( - [sys.executable, "-c", script], capture_output=True, text=True, timeout=120, check=True + [sys.executable, "-c", script], + capture_output=True, + text=True, + encoding="utf-8", + env={**os.environ, "PYTHONIOENCODING": "utf-8"}, + timeout=120, + check=True, ) assert result.stdout.strip().endswith("ok")