[Python-ideas] Official site-packages/test directory

Petr Viktorin encukou at gmail.com
Fri Jan 19 12:34:15 EST 2018


FWIW, I've had very good experience with putting tests for package `foo` 
in a directory/package called `test_foo`.

This combines the best of both worlds -- it can be easily separated for 
distribution (like `tests`), and it doesn't cause name conflicts (like 
`foo.tests`).


On 01/19/2018 05:23 PM, Paul Moore wrote:
> Another common approach is to not ship tests as part of your (runtime)
> package at all - they are in the sdist but not the wheels nor are they
> deployed with "setup.py install". In my experience, this is the usual
> approach projects take if they don't have the tests in the package
> directory. (I don't think I've *ever* seen a project try to install
> tests except by including them in the package directory...)
> 
> Paul
> 
> On 19 January 2018 at 16:10, Guido van Rossum <guido at python.org> 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
>> layout.
>>
>> On Fri, Jan 19, 2018 at 6:27 AM, Stefan Krah <stefan at bytereef.org> wrote:
>>>
>>>
>>> Hello,
>>>
>>> I wonder if we could get an official site-packages/test directory.
>>> Currently
>>> it seems to be problematic to distribute tests if they are outside the
>>> package
>>> directory.  Here is a nice overview of the two main layout possibilities:
>>>
>>>
>>> http://pytest.readthedocs.io/en/reorganize-docs/new-docs/user/directory_structure.html
>>>
>>>
>>> I like the outside-the-package approach, mostly for reasons described very
>>> eloquently here:
>>>
>>>
>>> http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html
>>>
>>>
>>> CPython itself of course also uses Lib/foo.py and Lib/test/test_foo.py, so
>>> it
>>> would make sense to have site-packages/foo.py and
>>> site-packages/test/test_foo.py.
>>>
>>> For me, this is the natural layout.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
> 



More information about the Python-ideas mailing list