Skip to content

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

Closed

Description

@pytestbot

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.


Activity

  1. pytestbot commented on Jan 23, 2014

    @pytestbot
    ContributorAuthor

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


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

  2. added
    type: enhancementnew feature or API change, should be merged into features branch
    on Jun 15, 2015
  3. RonnyPfannschmidt commented on Apr 20, 2016

    @RonnyPfannschmidt
    Member

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

  4. RonnyPfannschmidt commented on Mar 1, 2020

    @RonnyPfannschmidt
    Member

    it actually is

  5. blueyed commented on Mar 1, 2020

    @blueyed
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions