Modular / recursive configuration with multiple pytest.ini in subfolders #7732
-
Hi, i have been searching around about this, but could not find any info. My question is, is it possible somehow to use multiple pytest.ini files in subfolders? What I would like to achieve is that I have a package with several subfolders/subpackages that may contain python files that may contain test functions. These files may not have the |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
You can use https://docs.pytest.org/en/stable/reference.html#globalvar-collect_ignore_glob in a |
Beta Was this translation helpful? Give feedback.
-
How would that help? I need the opposite, I don't want to ignore some files, I would like to additionally collect some. Meanwhile I have played around with |
Beta Was this translation helpful? Give feedback.
-
Multiple ini files are not supported and at the moment there are no plans for this, as currently there is no reasonable and time effective way to implement this as a working solution Pytest itself has a hack in the root ini file to support this edit see line 16 of our pyproject.toml (can't make a proper link on mobile) |
Beta Was this translation helpful? Give feedback.
-
Thanks. So I guess I would be better off by reorganizing the project and extracting all tests to a separate tests folder. However I still see this as a possible feature, because in our case it is a quite big codebase, and in this case it would be better to have the tests next to the actual modules, or even inside them. |
Beta Was this translation helpful? Give feedback.
-
I suppose you could alternatively write a plugin to achieve this (not very familiar with this myself, but seems doable). https://hackebrot.github.io/pytest-tricks/customize_class_collection/ |
Beta Was this translation helpful? Give feedback.
-
@waszil How did you solve this? |
Beta Was this translation helpful? Give feedback.
-
closing this discussion as config merges are currently not supported and there are no plans to directly include such a feature and there also is no proposal on how to do this safe/sane |
Beta Was this translation helpful? Give feedback.
Multiple ini files are not supported and at the moment there are no plans for this, as currently there is no reasonable and time effective way to implement this as a working solution
Pytest itself has a hack in the root ini file to support this
edit see line 16 of our pyproject.toml (can't make a proper link on mobile)