python-3.x - VSCode pytest 测试发现失败?
问题描述
出于某种原因,VSCode 没有获取我的“test_*”文件?
这是代码:
import pytest
import requests
import responses
@responses.activate
def test_simple(api_key: str, url: str):
"""Test"""
responses.add(responses.GET, url=url+api_key,
json={"error": "not found"}, status=404)
resp = requests.get(url+api_key)
assert resp.json() == {"error": "not found"}
我试过使用 CTRL+SHIFT+P 和配置测试,但这也失败了,它说:Test discovery failed
和 Test discovery error, please check the configuration settings for the tests.
在我的设置中,唯一与 pytest 相关的是:"python.testing.pytestEnabled": true
.
这里发生了什么?我的文件以“test”开头,我在该文件中的函数也是如此吗?