尽管我可以在CMD中运行它们,但Visual Studio Code无法发现我的测试文件。
settings.json:
{
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"python.pythonPath": "C:/Users/CEM/Anaconda3/python.exe",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"python.testing.pyTestEnabled": true,
"python.testing.pyTestPath": "C:\\Users\\CEM\\Anaconda3\\Scripts\\pytest.exe",
"pythonTestExplorer.testFramework": "pytest",
"python.testing.cwd": ""
}
Visual Studio代码版本:
Version: 1.34.0 (user setup)
Commit: a622c65b2c713c890fcf4fbf07cf34049d5fe758
Date: 2019-05-15T21:59:37.030Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134
Python 3.6.8 64位作为Anaconda安装的一部分
文件结构:
> main folder
>> subfolder
>>> script.py
>>> __init__.py
>> test_folder
>>> __TEST__
>>>> (here are testing data files, .csv etc.)
>>> test.py
>>> __init__.py
功能代码:
import pytest
import numpy as np
import pandas as pd
from subfolder.script import func
class Test:
def test_zero_variance_filter(self):
assert 2 == 2
当我在cmd中运行时:
...test folder directory...>pytest -q test.py
测试正常运行,无论输出是否成功,我都会看到输出。
我使用设置(例如更改python环境,设置临时测试环境),尝试了不同的文件夹位置,重新启动VSC,正在检查是否所有扩展名都存在,但没有起作用。有什么建议吗?