Search code examples
pythonvisual-studio-codevscode-debugger

Python slash testing framework and vscode debugging


I'm trying to set a launch.json config file to be able to debug a slash run.

To run slash form the terminal I just need to:

slash run

This is my launch.json file:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "module": "slash",
        "args": [
            "run",
            "-vvv",
            "${file}"
        ],
        "console": "integratedTerminal",
      }
    ]
 }

But I receive

No module named slash.main; 'slash' is a package and cannot be directly executed

This is the command vscode is trying to run:

c:; cd 'c:\Users\dev\projects'; & 'c:\Users\dev\projects\.venv\Scripts\python.exe' 'c:\Users\dev\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher' '65500' '--' '-m' 'slash' 'run' '-vvv'

A test example that slash can run:

# test_addition.py

import slash

def test_addition():
    pass

any idea on how I can get this working?

any help is much appreciated.

Thanks


Solution

  • I found the solution for this.

    Just create this launch.json inside the .vscode folder

    {
          "version": "0.2.0",
          "configurations": [
          {
             "name": "slash testing",
             "type": "python",
             "request": "launch",
             "module": "slash.frontend.main",
             "args": [
                 "run",
                 "-vvv"
             ],
             "console": "integratedTerminal",
             "justMyCode": false
          }
       ]
    }
    

    So I needed to change the module name.