rpm-software-management / rpmlint

Tool for checking common errors in rpm packages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the purpose of the conftest.py file in the root directory of a repository?

afrid18 opened this issue · comments

It was written that having conftest.py file at root level will add rootdir(repo's path) to sys.path. But having any of the pytest config files(setup.cfg, pytest.ini, conftest.py, tox.ini etc), should have the same effect. But I guess conftest.py at root level is serving more, than just by adding rootdir(of repo) to sys.path.

Here are some screenshots.

Having conftest.py, configfile is setup.cfg, which is actually responsible for rootdir according to pytest documentation.

image

Not Having conftest.py, In this screenshot I have removed conftest.py file and still the rootdir is still the same (which conftest.py file's intention actually was) and yet tests (30 tests) are failing.

image

I am curios to know what actually is conftest.py at root level of the project is serving? Why do we still need it if it's only adding rootdir to sys.path which actually pytest.ini file is doing, see #1047

Hello.

It was me who added the file so that we don't have the following import module errors: ModuleNotFoundError: No module named 'rpmlint'.

I am curios to know what actually is conftest.py at root level of the project is serving? Why do we still need it if it's only adding rootdir to sys.path which actually pytest.ini file is doing, see #1047

I've tried your patch and removed the conftest.py and I still the import errors. Or do you see different results?

One last note: please do not attach console screenshots, use rather code blocks, it's better as one can copy from such text block.

Hi.

I've tried your patch and removed the conftest.py and I still the import errors. Or do you see different results?

My PR's intention was just to add pytest.ini file so that it is easy to manage pytest related configuration. Also pytest documentaion recommends to not use setup.cfg file to store pytest related configuration.

I've tried your patch and removed the conftest.py and I still the import errors. Or do you see different results?

Yes, I also have same error as you mentioned. But when ran with python -m pytest I don't see any tests failing. Another way is to use a virtual Environment and install editable installer using pip install -e . in project directory.

However, I haven't encountered this kind of behaviour with other projects that make use of pytest. Do you know any specific reason behind this? Please let me know.

One last note: please do not attach console screenshots, use rather code blocks, it's better as one can copy from such text block.

Sure 😅.

Yes, I also have same error as you mentioned. But when ran with python -m pytest I don't see any tests failing.

Well, I see it comfortable to run pytest from the root directory, thus I'm closing this issue. We don't need to be so pedantic.