Debug FastAPI no VS Code (pt-br)

Jul 7, 2022 min read

Configuração do VS Code para o debug do FastAPI, e para debug dos testes, via pytest.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run FastAPI",
      "type": "python",
      "request": "launch",
      "program": "./main.py",
      "console": "integratedTerminal",
      "justMyCode": true
    },
    {
      "name": "PyTest",
      "type": "python",
      "request": "launch",
      "stopOnEntry": false,
      //USE IF NEEDED "pythonPath": "${config:python.pythonPath}",
      "module": "pytest",
      "args": [
          "-sv"
      ],
      "cwd": "${workspaceRoot}",
      "env": {},
      "envFile": "${workspaceRoot}/.env",
      "debugOptions": [
          "WaitOnAbnormalExit",
          "WaitOnNormalExit",
          "RedirectOutput"
      ]
    }
  ]
}