[Python-ideas] Official site-packages/test directory
stephane at wirtel.be
Fri Jan 26 10:45:34 EST 2018
Sometimes, I need to read the tests of a package because I don't
understand the usage of a function/method/class and unfortunately, there
is no documentation. In this case, and only in this case, I will try to
find the tests and in the worst case, download the source and try to
understand with the 'tests' directory.
my 0.000002 € ;-)
On 01/26, Barry Warsaw wrote:
>Guido van Rossum wrote:
>> IIUC another common layout is to have folders named test or tests inside
>> each package. This would avoid requiring any changes to the site-packages
>That's what I do for all my personal code. Yes, it means the test
>directories are shipped with the sdist, but really who cares? I don't
>think I've had a single complaint about it, even with large-ish projects
>like Mailman. I can see you wanting to do something different if your
>project has truly gargantuan test suites, but even with 100% coverage
>(or nearly so), I think size just isn't usually a big deal.
>In another message, Giampaolo describes being able to run tests with -m
>psutil.test. That's a neat idea which I haven't tried. But I do think
>including the tests can be instructive, and I know that on more than one
>occasion, I've cracked open a project's test suite to get a better sense
>of the semantics and usage of a particular API.
>Finally, I'll disagree with pytest's recommendation to not put
>__init__.py files in your test directories. Although I'm not a heavy
>pytest user (we use it exclusive at work, but I don't use it much with
>my own stuff), having __init__.py files can be useful, especially if you
>also have test data you want to access through pkg_resources, or now,
>importlib_resources (importlib.resources in Python 3.7).
Stéphane Wirtel - http://wirtel.be - @matrixise
More information about the Python-ideas