VS Code / Python / Debugging pytest Test with the Debugger

If you want to enter debugging when running pytest in VSCode and stay at a line of code, you could click ‘Debug Test‘ at the top of the method after selecting the pytest test, as shown in the screenshot:

enter image description here

In addition, "python.testing.pytestArgs": [], in .vscode\settings.json is the folder path of the tested file, for example, my test file is in Test_cc under the a folder.

>      "python.testing.pytestArgs": [
>             "a/Test_cc"
>         ],

If this is not what you want, please let me know and describe the details of your needs.

Reference: Debug tests.

Update:

Usually, when we debug the test in VSCode, without setting a breakpoint for it, it will only display the test result. (success or failure).
It will only display relevant test information in the console OUTPUT.

When I use the extension ‘Python Test Explorer for Visual Studio code‘, it will display the debugging test information on the console, prompting the issue.

enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)