pycharm终端运行出现test session starts
调试功能能函数的时候,发现终端窗口不一样。出现了新的运行模式。
终端内容如下:
d:\anaconda\python.exe "d:\pycharm community edition 2021.2.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --path d:/lskj/xxxx/test/1.py testing started at 17:10 ... launching pytest with arguments d:/lskj/xxxx/test/1.py --no-header --no-summary -q in d:\lskj\xxxx\test ============================= test session starts ============================= collecting ... collected 1 item 1.py::test_xxxx error [100%] test setup failed file d:\lskj\xxxx\test\1.py, line 14 def test_xxxx(line_str): e fixture 'line_str' not found > available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, 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. d:\lskj\xxxx\test\1.py:14 ========================= 1 warning, 1 error in 5.77s ========================= process finished with exit code 1
百度了下。。。
原来是进入了pycharm的测试用例模式。
解决办法
1.检查测试函数名称 是否以 ‘test’ 开头;
2.检查测试类名称 是否以‘test’开头,但是类中不能有init方法;
3.检查测试文件名称是否以‘test’/‘test’开头,或者以‘test’/‘test’结尾。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论