Files
hello-algo/ja/codes/python/test_all.py
T
Yudong Jin 7257641e0e Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese

* Fit Japanese homepage labels and localize heading permalinks

* Point Japanese contribution instructions to the Japanese preview

* Replace locale conditionals with multilingual UI tables
2026-10-30 02:12:26 +08:00

34 lines
1.0 KiB
Python

import os
import glob
import subprocess
env = os.environ.copy()
env["PYTHONIOENCODING"] = "utf-8"
if __name__ == "__main__":
# ソースコードのファイルを探す
src_paths = sorted(glob.glob("chapter_*/*.py"))
errors = []
# Python コードを実行する
for src_path in src_paths:
process = subprocess.Popen(
["python", src_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
env=env,
encoding='utf-8'
)
# プロセスの終了を待ち、出力とエラーメッセージを取得する
stdout, stderr = process.communicate()
# 終了ステータスを確認する
exit_status = process.returncode
if exit_status != 0:
errors.append(stderr)
print(f"{len(src_paths)} 個のファイルをテストしました")
print(f"{len(errors)} 個のファイルで例外が見つかりました")
if len(errors) > 0:
raise RuntimeError("\n\n".join(errors))