Pyest不会在单独的文件夹中检测到固定装置
我有一个使用Pytest和Pytest固定装置的Django应用程序,并且正在编写测试。
所有测试都在其各自的Django应用程序中,但我以其他文件夹为模块编写了固定装置。
项目结构:
Proj.
|
+apps:
- core
-tests
-test_core.py
- users
-tests
test_user.py
|
+fixtures:
- __init__.py
- core.py
- users.py
|
+conftest.py
我的单独文件中有不同的固定装置,这些固定装置与要使用的应用程序名称相对应。
我尝试在项目的根部创建一个Conftest.py文件,并将固定文件作为插件导入conftest.py文件,这是有问题的。
conftest.py
> pytest_plugins = [
"apps.fixtures",]
我还尝试过删除coftest.py文件,并将固定文件放在应用程序文件夹中,而仍然没有检测到固定装置。
这里的任何帮助都会有所帮助。
I have a Django application and am writing tests using pytest and pytest fixtures.
All the tests are in their respective Django apps but I wrote the fixtures in a different folder as a module.
Project structure:
Proj.
|
+apps:
- core
-tests
-test_core.py
- users
-tests
test_user.py
|
+fixtures:
- __init__.py
- core.py
- users.py
|
+conftest.py
I have the different fixtures in their separate files which correspond with the app names they are to be used.
Am having problems with pytest detecting the fixtures I have tried creating a conftest.py file in the root of the project and importing the fixtures file as a plugin.
conftest.py
> pytest_plugins = [
"apps.fixtures",]
I have also tried removing the coftest.py file and placing the fixtures file in the apps folder and still pytest does not detect the fixtures.
Any help here would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,不需要插件,只需将它们导入
conftest.py
即可使它们可用于所有测试文件。Plugins are not needed for this, simply import them into
conftest.py
to make them available to all test files.