Skip to content

Config variable to set locations to try for conftest.py files #430

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

Closed
pytestbot opened this issue Jan 23, 2014 · 4 comments · Fixed by #10988
Closed

Config variable to set locations to try for conftest.py files #430

pytestbot opened this issue Jan 23, 2014 · 4 comments · Fixed by #10988
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: holger krekel (BitBucket: hpk42, GitHub: hpk42)


Discussed with @jurko and others: It would be good to have a conftestscan ini variable which you can set in order to have pytest scan for conftest files. Examples:

  • conftestscan = test*/conftest.py (the default) would make pytest look for a conftest.py in any sub directory of the directory containing the ini-file.
  • conftestscan = test*/**/conftest.py would make pytest do a recursive search in all subdirs.
  • conftestscan = myproj/**/conftest.py would make pytest scan all subdirs in the project/package directory for conftest.py files.

Note that the only effect of conftestscan is to load conftest files early and make e.g. its command line options available. Any fixture functions or e.g. pytest_runtest_* hooks would still only be available to all the tests under the directory of the respective conftest.py file where they are defined. In other words, conftestscan does not turn conftest.py into global plugins.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


Issue #416 was marked as a duplicate of this issue.

@RonnyPfannschmidt
Copy link
Member

@hpk42 is this sill an issue after we already support local plugins and opt out of deep scan?

fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
this should allow precommit hooks to be used with py37
@RonnyPfannschmidt
Copy link
Member

it actually is

@blueyed
Copy link
Contributor

blueyed commented Mar 1, 2020

Ref:

for x in anchor.listdir("test*"):
- took me a while recently to figure out why testmeh/conftest.py was used (within a test), but meh/conftest.py was not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants