Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to load initial conftest.py from rootdir rather than current working directory #9311

Open
henzef opened this issue Nov 15, 2021 · 3 comments
Labels
topic: config related to config handling, argument parsing and config file type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@henzef
Copy link

henzef commented Nov 15, 2021

Would it be possible to add an option to load the initial conftest.py from the rootdir (which can be specified on the commandline) instead of using the automatic discovery that is explained in https://docs.pytest.org/en/6.2.x/writing_plugins.html#plugin-discovery-order-at-tool-startup ?

This seems to be the missing piece of the puzzle that would allow me to execute my test suite independently from the current working directory.
Consider e.g. the following commandline:

pytest -c /home/user/project/pytest.ini --rootdir=/home/user/project --an-argument-of-my-plugin=./some/relative/path

which only works if the current working directory is below /home/user/project. For now I used a wrapper script that changed the cwd before starting pytest, but this fell apart when I introduced commandline arguments that take a (possibly relative) path.

@Zac-HD Zac-HD added topic: config related to config handling, argument parsing and config file type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature labels Nov 16, 2021
kdeldycke added a commit to kdeldycke/meta-package-manager that referenced this issue May 28, 2023
@kdeldycke
Copy link

Is this solve in 8.1.0 with #11962 ?

@henzef
Copy link
Author

henzef commented Mar 4, 2024

If understand the pyproject.toml discovery correctly, it starts searching from the current working directory, right? If yes, then it will not help in this case.

kdeldycke added a commit to kdeldycke/meta-package-manager that referenced this issue May 27, 2024
@kdeldycke
Copy link

I don't know if this is a combination of recent Pytest or Poetry upgrade, but moving my tests from my_package/tests/* to the root of my repository at tests/* seems to have fixed the issue for me.

And this over 3 different projects:

Pretty sure forcing a code layout is not a definitive solution though, but wanted to keep this issue up to date with my current observations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: config related to config handling, argument parsing and config file type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

3 participants