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

Move tests out of package and into top-level directory #2381

Closed
wants to merge 1 commit into from

Conversation

jdufresne
Copy link
Contributor

This follows the "Tests outside application code" pattern documented in
the pytest guides. See:
https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#tests-outside-application-code

This has the following benefits:

  • Your tests can run against an installed version after executing pip
    install ..

  • Your tests can run against the local copy with an editable install
    after executing pip install --editable ..

  • If you don’t use an editable install and are relying on the fact
    that Python by default puts the current directory in sys.path to
    import your package, you can execute python -m pytest to execute the
    tests against the local copy directly, without using pip.

This keeps tests separate from actual library code. End users don't need
the tests mixed in with the installed packages. Instead, tests are only
interesting to library developers and packagers. The tests remain
available, just moved.

@luzpaz luzpaz requested a review from peternewman June 27, 2022 11:12
@larsoner
Copy link
Member

I'm not totally convinced. Most scientific Python packages (numpy, scipy, scikit-learn, etc.) package within the module. Often tests change along with the library (exceptions, new tests, etc.) so I'm not sure there is too much value added here for "running tests against other versions", which seems to be the primary motivation in the pytest docs.

This follows the "Tests outside application code" pattern documented in
the pytest guides. See:
https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#tests-outside-application-code

> This has the following benefits:
>
> - Your tests can run against an installed version after executing pip
> install ..
>
> - Your tests can run against the local copy with an editable install
> after executing pip install --editable ..
>
> - If you don’t use an editable install and are relying on the fact
> that Python by default puts the current directory in sys.path to
> import your package, you can execute python -m pytest to execute the
> tests against the local copy directly, without using pip.

This keeps tests separate from actual library code. End users don't need
the tests mixed in with the installed packages. Instead, tests are only
interesting to library developers and packagers. The tests remain
available, just moved.
@DimitriPapadopoulos
Copy link
Collaborator

Moving to pyproject.toml and changes in tests require resolving conflicts, probably complex ones.

Also, it looks like this change did not convince: it's one set of conventions against another. Why change and not stick with the initial conventions?

@jdufresne jdufresne closed this Apr 28, 2023
@jdufresne jdufresne deleted the move-tests branch April 28, 2023 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants