VSCode 在 Python 中显示重复测试

问题描述 投票:0回答:1

我不知道这是否是由于最近的更新所致,但我看到我的 Python 测试出现了两次,当我处于测试调试模式时,它也运行了两次。我该如何解决这个问题?我刚刚创建了一个空项目,但遇到了同样的问题。

重现步骤:

  1. python -m venv .venv
    (创建虚拟环境)

  2. source ./.venv/bin/activate
    (激活virtualenv)

  3. pip install pytest==8.3.3

  4. 在 VSCode 上选择 Python 解释器作为 virtualenv 。

  5. mkdir server server/tests

  6. 基本测试文件

    # server/tests/test_storage.py
    import pytest
    
    class TestStorage:
        def test(self):
            pass
    
  7. Settings.json(我尝试了目录的不同变体)

    {
      "python.testing.pytestArgs": [
        "tests"
      ],
      "python.testing.unittestEnabled": false,
      "python.testing.pytestEnabled": true
    }
    

Screenshot of test module Screenshot 2 enter image description here

VSCode 版本:1.94.0(通用)

python visual-studio-code pytest vscode-debugger
1个回答
0
投票

事实证明,这是由于启用了 PythonPython Test Explorer for Visual Studio Code 扩展,它们都具有测试功能。禁用后者解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.