pytest fixtures in a separate directory

做~自己de王妃 提交于 2019-11-30 20:57:24
sax

read here how structure your test.

your fixture directory seems not in package (project does not have __init__.py so canno be imported as project.fixtures either as fixtures as is not in the path. You can add required dirs in the path in your tests/conftest.py (sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, "fixtures")) or sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir) depending how how you want import your modules.

Please add in your conftest.py

  import pytest

  pytest_plugins = [
   "fixtures.conftest",
   "fixtures.fixture_cifs",
   "fixtures.fixture_ftp",
   "fixtures.fixture_service"
  ]

After the all of declared additional fixtures will be founded by pytest

As a note that the respective directories referred to in fixtures.conftest" need to have __init__.py files for the plugins to be loaded by pytest

Please read about similar case here: https://stackoverflow.com/a/54736237/6655459

Did you try importing your fixtures in project/conftest.py? Is that what you mean by "wrappers to return an instance"?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!