From 8f9333e7448ede120c8b3cc3c30500e62c2d7b20 Mon Sep 17 00:00:00 2001 From: Jhonathan Abreu Date: Tue, 7 May 2024 10:47:25 -0400 Subject: [PATCH] Extend unit tests and update readme --- README.md | 2 +- lean/commands/backtest.py | 2 +- tests/commands/test_backtest.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index df71f3e4..88459e28 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Usage: lean backtest [OPTIONS] PROJECT Options: --output DIRECTORY Directory to store results in (defaults to PROJECT/backtests/TIMESTAMP) -d, --detach Run the backtest in a detached Docker container and return immediately - --debug [pycharm|ptvsd|vsdbg|rider|local-platform] + --debug [pycharm|ptvsd|debugpy|vsdbg|rider|local-platform] Enable a certain debugging method (see --help for more information) --data-provider-historical [Interactive Brokers|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Kraken|IQFeed|Polygon|FactSet|IEX|AlphaVantage|CoinApi|ThetaData|QuantConnect|Local|Terminal Link|Bybit] Update the Lean configuration file to retrieve data from the given historical provider diff --git a/lean/commands/backtest.py b/lean/commands/backtest.py index b0280878..9c0836d2 100644 --- a/lean/commands/backtest.py +++ b/lean/commands/backtest.py @@ -234,7 +234,7 @@ def _migrate_csharp_csproj(project_dir: Path) -> None: default=False, help="Run the backtest in a detached Docker container and return immediately") @option("--debug", - type=Choice(["pycharm", "ptvsd", "vsdbg", "rider", "local-platform"], case_sensitive=False), + type=Choice(["pycharm", "ptvsd", "debugpy", "vsdbg", "rider", "local-platform"], case_sensitive=False), help="Enable a certain debugging method (see --help for more information)") @option("--data-provider-historical", type=Choice([dp.get_name() for dp in cli_data_downloaders], case_sensitive=False), diff --git a/tests/commands/test_backtest.py b/tests/commands/test_backtest.py index 9a3a373d..80d48260 100644 --- a/tests/commands/test_backtest.py +++ b/tests/commands/test_backtest.py @@ -283,6 +283,8 @@ def _ensure_rider_debugger_config_files_exist(project_dir: Path) -> None: ("PTVSD", DebuggingMethod.PTVSD), ("vsdbg", DebuggingMethod.VSDBG), ("VSDBG", DebuggingMethod.VSDBG), + ("debugpy", DebuggingMethod.DebugPy), + ("DebugPy", DebuggingMethod.DebugPy), ("rider", DebuggingMethod.Rider), ("Rider", DebuggingMethod.Rider)]) def test_backtest_passes_correct_debugging_method_to_lean_runner(value: str, debugging_method: DebuggingMethod) -> None: @@ -348,7 +350,8 @@ def test_backtest_auto_updates_outdated_python_pycharm_debug_config() -> None: assert workspace_xml.find(".//mapping[@remote-root='/Lean/Launcher/bin/Debug']") is None -def test_backtest_auto_updates_outdated_python_vscode_debug_config() -> None: +@pytest.mark.parametrize("value", ["ptvsd", "debugpy"]) +def test_backtest_auto_updates_outdated_python_vscode_debug_config(value) -> None: create_fake_lean_cli_directory() lean_config_manager = container.lean_config_manager @@ -380,7 +383,7 @@ def test_backtest_auto_updates_outdated_python_vscode_debug_config() -> None: ] })) - result = CliRunner().invoke(lean, ["backtest", "Python Project", "--debug", "ptvsd"]) + result = CliRunner().invoke(lean, ["backtest", "Python Project", "--debug", value]) assert result.exit_code == 0