Python
test(cli): read the backtest help without terminal styling
Yijia-Xiao76a93d615ae2
diff --git a/tests/test_cli_commands.py b/tests/test_cli_commands.pyindex 107973435..c0fb5f727 100644--- a/tests/test_cli_commands.py+++ b/tests/test_cli_commands.py@@ -82,13 +82,17 @@ class _Summary:def test_every_command_is_registered_when_run_as_a_module():"""README documents `python -m cli.main`, which executes the file top tobottom, so a command defined after the __main__ block would not exist."""+ import reimport subprocessimport sysout = subprocess.run([sys.executable, "-m", "cli.main", "backtest", "--help"],capture_output=True, text=True, timeout=120)assert out.returncode == 0, out.stderr[-400:]- assert "--start" in out.stdout+ # Where the terminal takes colour, help styles each option and splits+ # "--start" across escape sequences, so read the text without them.+ plain = re.sub(r"\x1b\[[0-9;]*m", "", out.stdout)+ assert "--start" in plain@pytest.mark.unit