VSCode debugging with instance and tests using your existing buildout

You might not be aware but the full power of vscode debugging with breakpoints, auto breakpoints on exceptions etc is available to you right now with your current buildout. No need to wait for pip based plone 6. Works great for zopetest, robot tests also.

to get this all I did was add this part to the buildout (and include it in parts)

[vscode]
recipe = collective.recipe.vscode >= 0.1.8

you don't even need to tell it where the eggs are (but you can if you want).

and then add a .vscode/launch.json with config similar to

{
    // 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": "test",
            "type": "python",
            "request": "launch",
            "program": "./bin/test",
            "console": "integratedTerminal"
        },
        {
            "name": "instance fg",
            "type": "python",
            "request": "launch",
            "program": "bin/instance",
            "args": ["fg"],
            "console": "integratedTerminal",
        }
    ]
}

NB: @pbauer showed a trick at the conf that gets you pylance analysis by selecting the interpreter as buildout generated zopepy interpreter. This unfortunately doesn't work for debugging/running. Keep your python to the same in your venv etc and do the above and everything now works including pylance, jump to declarations etc.

Screen Shot 2021-11-24 at 12.15.38 pm

Due to the way vscode works you can't browse or use "find" on your buildout eggs as nicely as you could with pycharms buildout support. But once you jump into egg code you can use the breadcrumbs to navigate around that package.

and you use cmd-p @ to find by symbol

I guess omelette recipe lets you browse but I try to avoid it so not sure how it works with this approach.

2 Likes

I installed the vscode recipe as described here, and it's installed successfully and the eggs paths are added to the python interpreter, I then added the above snippet to the .vscode/launch.json file, however, when I try to run the debugger I get the following error, Does anyone know what I'm doing wrong or might be missing?