[TIP] Advice on location of tests modules

John Wong gokoproject at gmail.com
Thu Feb 27 15:03:40 PST 2014


I am not sure if I understood your question entirely, so correct me if
necessary.

This is the source code I supposed:
https://svn.apache.org/repos/asf/bloodhound/trunk/

I've looked at the structure a bit and found that you currently have tests
under each product/package (for example,
https://svn.apache.org/repos/asf/bloodhound/trunk/bloodhound_dashboard/bhdashboard/),
also see
https://svn.apache.org/repos/asf/bloodhound/trunk/bloodhound_dashboard/setup.py
)

I believe this means tests is also included in the package installation
(when you run setup.py)

I prefer not to do that. I prefer to have my test folder next to setup.py.
This means I shouldn't be importing bhdashboard.tests.test_xxxx   and there
is no reason to import that.

Should you combine all tests in a single directory? Examples:
https://svn.apache.org/repos/asf/bloodhound/trunk/tests
https://svn.apache.org/repos/asf/bloodhound/trunk/tests/product1/
https://svn.apache.org/repos/asf/bloodhound/trunk/tests/product1/unittest
https://svn.apache.org/repos/asf/bloodhound/trunk/tests/product1/functional
and so on

I wouldn't do that. Each python package (I go by product1, product2,
product3 here) should have its own tests directory (sits next to setup.py).
If two packages share a lot of test utilities scripts (I call them test
drivers), consider making those utilities into separate python package.

That's just me. Most of my projects will end up in some PyPI data store
(public or private) so I have a good reason to keep test folder separate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140227/81337869/attachment.htm>


More information about the testing-in-python mailing list