打开settings
打开扩展–> 找到python --> 打开json配置
将cv2的安装目录配置到如下位置
具体为啥不行没搞明白
当方法以test开头的时候会自动识别成测试用例,会有一个标识,鼠标右键点击标识的时候可以执行测试,如果成功就会出现一个对号
import pytest from src import base_function as bf print(bf.getCurrentAsbDir()) def test_getCurrentAsbDir(): assert bf.getCurrentAsbDir() == "e:\learning_sources\cv_py" def aaa(): assert 1==1 def test_aaa(): assert 1==1
PYTHONPATH="E:/learning_sources/cv_py/src;E:/learning_sources/cv_py/src/tests;E:/learning_sources/cv_py;${env:PYTHONPATH}"
{ "python.analysis.autoImportCompletions": true, // "python.envFile": "E:/learning_sources/cv_py/.env", //这里是配置运行时的工作路径 "terminal.integrated.env.windows": {"PYTHONPATH":"${workspaceFolder};${env:PYTHONPATH}"}, "python.defaultInterpreterPath": "D:\\ProgramData\\anaconda3\\python.exe" }
参考:
https://blog.csdn.net/qq_31654025/article/details/109474175
import pytest from src import base_function as bf print(bf.getCurrentAsbDir())
安装插件 Black Formatter 插件
修改setting.json配置内容如下
{ "python.formatting.provider": "none", "python.formatting.autopep8Args": [ "--max-line-length=150" ], "editor.wordWrap": "on", "editor.wordWrapColumn": 150, "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true, "editor.formatOnPaste": true, "editor.formatOnType": true, }, "black-formatter.args": [ "--line-length", "150" ], }