python 3.X报错pytest系列问题
1.ModuleNotFoundError: No module named ‘pytest’
这种问题一般是使用如下命令解决:
pip install pytest
这个下载完毕之后,如果问题还没有解决,可以查看一下在运行的.py文件中是否定义了含有test或test_的函数,如果有的话,尝试如下解决方案:
2. available fixtures: cache, capfd, capfdbinary, caplog, capsys,… -use ‘pytest --fixtures [testpath]’ for help on them.
=================================== ERRORS ====================================
___________________________ ERROR at setup of test ____________________________
file C:\Users\kingback\Desktop\代码\Prototypical-Networks-for-Few-shot-Learning-PyTorch-master\src\train_liupai.py, line 178
def test(opt, test_dataloader, model):
E fixture 'opt' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
出现这个问题是因为我的代码中含有test的一个函数,而与python中的默认执行的test函数冲突,所以出现上图所示错误,解决方案就是将含有test或test_的函数变一个名字即可。此处我将test函数更名为king_test就没再报错了。