Repository navigation
docs: add guide on in-tree tests for packages with compiled code - #821
InessaPawson wants to merge 2 commits into
Conversation
👷 Deploy request for python-package-guide pending review.Visit the deploys page to approve it
|
aacb348 to
bf34ca8
Compare
|
This is great. i'd love @ucodery to have a look. We talked a lot about non-pure Python packages and cases where you want to ship tests. i just want another set of eyes on this one if possible as I am not the expert here but recall many long debates about this. !! |
ucodery
left a comment
There was a problem hiding this comment.
This guide looks great. My only two followups, not blocking
Even when a package does choose to include tests, it is often done as part of the sdist building, yet still left out of any wheels. If the tests aren't included in wheels, this also allows the tests to remain out-of-tree and then explicitly added for the sdist step (I believe all backends could be configured to do this, setuptools explicitly outlines how to do this).
Smaller nit, pytest is only required if the package is using pytest imports. If the package is using unittest, It would be better to not include an extras requirement for end users, even if the development workflow uses pytest as a test runner. (or if some other framework, that would need to be the requirement)
889dc2b to
86811f8
Compare
86811f8 to
7b2baf7
Compare
ucodery
left a comment
There was a problem hiding this comment.
I think this this explainer is great! Often being one of those downstream packagers, this is all the best advice we can give, with a lot of supporting arguments and examples. It is a bit in the weeds, but I would hope that would enlighten those who seek an answer to the question of shipping tests.
One final quibble, the page is still called in-tree tests, but it is more about including tests in distributions, in which in-tree is just one way.
| ```text | ||
| graft tests | ||
| ``` | ||
| This does not itself control wheel contents: ensure `tests/` is not selected |
There was a problem hiding this comment.
I don't think we need to ask a packaging learner to ensure that a sibling tests isn't installed by a wheel build? That's pretty technical, and if they are following all our guidance, even these optional bits, it won't get included.
| If distributed tests or a public test helper require third-party dependencies, | ||
| projects may declare those dependencies in a `test` extra to support running |
There was a problem hiding this comment.
| If distributed tests or a public test helper require third-party dependencies, | |
| projects may declare those dependencies in a `test` extra to support running | |
| If distributed tests or a public test helper require additional third-party dependencies, | |
| projects may declare those dependencies in the same `test` extras group to support running |
Adds
tests/in-tree-tests.mdexplaining when to ship tests inside the package, how to lay them out, and how to run them.Linking the new page from
tests/index.mdandpackage-structure-code/python-package-structure.md.Closes #343.