当运行 python 代码时,出现了错误:
E fixture 'XXX' 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命名或者名字中包含test的python文件、类、方法、函数。
解决方法: 修改对应的文件,类,方法,函数的名字
我尝试了一下,把错误的函数名从 test
更改为 test1
,错误依旧存在。
然后把函数名改为 main
, 运行成功。