Search code examples
pythonpython-3.xtestingvisual-studio-codevscode-debugger

Arg override error with Python slash testing framework and vscode Debugger


I am trying to debug slash testing framework test using vscode.

slash run -o perf.ip=1.2.3.4 perf\test_perf.py -vvv

My launch.json looks as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "slash testing",
            "type": "python",
            "request": "launch",
            "module": "slash.frontend.main",
            "args": [
                "run",
                "-o",
                "perf.ip=1.2.3.4",
                "-vvv"
            ],
            "console": "integratedTerminal",
            "justMyCode": false,
            "cwd": "${workspaceFolder}\\code\\scripts\\python"
        }
    ]
}

When I debug the file, i get the following error in the terminal:

ERROR: slash.app: Unexpected error occurred
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\slash\app.py", line 119, in __enter__
    cli_utils.get_modified_configuration_from_args_context(self.arg_parser, self._parsed_args)
  File "C:\Python37\lib\contextlib.py", line 427, in enter_context
    result = _cm_type.__enter__(cm)
  File "C:\Python37\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\Python37\lib\site-packages\slash\utils\cli_utils.py", line 87, in get_modified_configuration_from_args_context
    to_restore.append((path, config.get_path(path)))
  File "C:\Python37\lib\site-packages\confetti\config.py", line 361, in get_path
    return self.get_config(path).get_value()
  File "C:\Python37\lib\site-packages\confetti\config.py", line 155, in get_config
    "Invalid path: {0!r}".format(path))
confetti.exceptions.InvalidPath: Invalid path: 'perf.ip'
ERROR: Unexpected error: Invalid path: 'perf.ip'

Is something misconfigured here? Running the slash command on cmd line works just fine but errors out on the the vscode debugger.


Solution

  • Resolved. After adding the file name AFTER the run arg in the list, it works fine. Seems like running through the vscode debugger/launch, the args are position dependent.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "slash testing",
                "type": "python",
                "request": "launch",
                "module": "slash.frontend.main",
                "args": [
                    "run",
                    "perf\\test_perf.py",
                    "-o",
                    "perf.ip=1.2.3.4",
                    "-vvv"
                ],
                "console": "integratedTerminal",
                "justMyCode": false,
                "cwd": "${workspaceFolder}\\code\\scripts\\python"
            }
        ]
    }