I am working on a pytest-framework that will be packed as a package. The setup file i am using for this is as this:
setup(
name='MyTestFrameWork',
version="2",
author='my name',
author_email='[email protected]',
description='My test framework',
long_description=open('README.md', 'rb').read().decode('utf-8'),
url='http://my.test.framework.dk',
license="Free loot",
packages=find_namespace_packages(),
python_requires=">=3.10",
include_package_data=True,
install_requires=['pytest'],
entry_points={"pytest11": ["MyTestFrameWork = MyTestFrameWork"]},
)
In this package (in the root of this folder MyTestFrameWork ) I have a conftest.py with some fixtures.
MY problem/Question: When I import my framework from another python project eg: by importing the testframework. I cant get the framework to use the fixtures in the conftest ...... however,....
if i move the content from the conftest.py into __init__.py
in my framework ie: in MyTestFrameWork folder the fixtures are working as expected.
why it is like this ....why cant i have my fixtures in the conftest.py instead of having them in the __init__.py
am i missing something ?
for better view of my file-structure on the framework:
CodePudding user response:
You are missing the conftest module in the entry_points
definition. The syntax is following:
entry_points={"pytest11": ["name_of_plugin = myproject.pluginmodule"]}
This means that for Pytest to load the fixtures from conftest.py, the setup should be following:
setup(
...
entry_points={"pytest11": ["MyTestFrameWork = MyTestFrameWork.conftest"]},
)
However, conftest.py is typically meant for auto-discovery within tests so in a plugin I'd actually use a different name for the module containing the fixtures.