Skip to content

TST: Why so many conftest.py files? #10310

Closed

Description

@pllim

Description

I see many copies of conftest.py files buried in the package. The most troubling are astropy/conftest.py and conftest.py that contain duplicated code.

  1. astropy/coordinates/tests/conftest.py
  2. astropy/table/tests/conftest.py
  3. astropy/wcs/tests/conftest.py
  4. astropy/wcs/wcsapi/conftest.py
  5. astropy/conftest.py
  6. docs/conftest.py
  7. conftest.py

Expected behavior

One and only one conftest.py at root directory.

Proposed solution

  • Move stuff from lower level conftest.py files to the root level one. Eliminated duplicate code.
  • Move subpackage specfici test helper functions into subpackage/tests/utils.py if they are not needed at the root conftest.py level.

Need to know

  • Is there a reason why proposed solution above wouldn't work?

Activity

  1. Cadair commented on May 5, 2020

    @Cadair
    Member

    Having lower level conftest files which provide subpackage specific pytest fixtures is the recommended way of doing it. ref

    I agree it can be a little magic as you have to look for conftest files to see where your fixtures are coming from, but I think it would cause more issues to try and work around pytest (pytest is sufficiently magic you are better off accepting the magic and becoming one with it than fighting against it imo).

    I do wonder if the very top most level conftest.py file should be removed, I know pytest has been deprecating stuff in there because the behaviour is ill defined.

  2. pllim commented on May 5, 2020

    @pllim
    MemberAuthor

    Really? I thought it is the other way around? I remember pytest chastising me in another package for having lower level conftest.py and implored me to use root-level one.

    Besides, we need the root-level one to run pytest ... from root level during dev testing locally.

  3. Cadair commented on May 6, 2020

    @Cadair
    Member

    🤷

  4. pllim commented on Jun 17, 2020

    @pllim
    MemberAuthor

    I think @astrofrog said something about the test runner. Ah well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions