import pytest
def test_main():
assert 5!=5
if __name__ == "__main__":
pytest.main()
在命令行又是可以正确找到虚拟环境pytest模块,在vscode里面运行提示找不到模块(vscode也是切换到虚拟环境得),报错如下:
[Running] python -u "d:\MyPytest\test_sample.py"
Traceback (most recent call last):
File "d:\MyPytest\test_sample.py", line 1, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
[Done] exited with code=1 in 0.176 seconds