簡體   English   中英

Python斜線測試框架和vscode調試

[英]Python slash testing framework and vscode debugging

我正在嘗試設置一個launch.json 配置文件以便能夠調試斜線運行。

要從終端運行斜線,我只需要:

slash run

這是我的 launch.json 文件:

{
// 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",
      }
    ]
 }

但我收到

沒有名為 slash 的模塊。 主要 'slash' 是一個包,不能直接執行

這是 vscode 試圖運行的命令:

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'

斜線可以運行的測試示例:

# test_addition.py

import slash

def test_addition():
    pass

關於如何讓這個工作的任何想法?

任何幫助深表感謝。

謝謝

我找到了解決方案。

只需在 .vscode 文件夾中創建這個 launch.json

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

所以我需要更改模塊名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM