Closed simonwaid closed 2 years ago
I noticed that placeholder and wondered if it was ever used. Anyway, you should write your tests just like code - use the package as if it was installed. Then only run the tests with it installed (including via editable mode if you are developing). They will be included in the SDist but not the wheel.
I agree that the tutorial should include basic testing, and started some work on that, as noted in https://github.com/pypa/packaging.python.org/issues/619#issuecomment-869146541. I'm still keen to get back to that, but it might be a bit. PR's welcome.
I'm closing this as a duplicate of that issue and #583
OS version
Ubuntu 22.04
Python version
3.10
Pip version
22.0.2
Guide link
https://packaging.python.org/en/latest/tutorials/packaging-projects/
Problem description
I've followed the tutorial to create a package for some code I had been working on for a while. My code contains unit tests and I regard them as essential. The tutorial says:
That's not very helpful, as I'd like to include my tests. So I tried things on my own, putting my tests inside the tests directory. Now I have the issue that I cannot include the other files from my tests. I get the error
ImportError: attempted relative import with no known parent package
.It would be great if you could at link to somewhere where it is described how to include unit tests or even better describe that in the tutorial.
Error message
No response