[TIP] Fwd: Advice on location of tests modules

Olemis Lang olemis at gmail.com
Thu Feb 27 15:51:02 PST 2014


---------- Forwarded message ----------
From: Olemis Lang <olemis at gmail.com>
Date: Thu, Feb 27, 2014 at 6:50 PM
Subject: Re: [TIP] Advice on location of tests modules
To: John Wong <gokoproject at gmail.com>



On Thu, Feb 27, 2014 at 6:03 PM, John Wong <gokoproject at gmail.com> wrote:

> 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/
>
>
yes


> 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
> )
>
>
The structure is like this

+ /trunk
| +-- bloodhound_dashboard
| |    +-- setup.py
| |    +-- bhdashboard
| |         +-- ... plugin source code with sub packages ...
| |         +-- tests
| |              +--- ... test code ...
| +-- bloodhound_multiproduct
| |    +-- setup.py
| |    +-- multiproduct
| |    |    +-- ... plugin source code with sub packages ...
| |    +-- tests
| |         +--- ... test code ...
| +-- bloodhound_relations
| |    +-- setup.py
| |    +-- bhrelations
| |         +-- ... plugin source code with sub packages ...
| |         +-- tests
| |              +--- ... test code ...
| +-- bloodhound_search
| |    +-- setup.py
| |    +-- bhsearch
| |         +-- ... plugin source code with sub packages ...
| |         +-- tests
| |              +--- ... test code ...
| +-- bloodhound_theme
| |    +-- setup.py
| |    +-- bhtheme
| |         +-- ... plugin source code with sub packages ...
| |         +-- tests
| |              +--- ... test code ...
| +-- trac


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

no, afaict those folders are ignored in setup.py pkg defintion . For
multiproduct module the separation is more obvious . Harder to see for trac
source tree .


>
> 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.
>

In fact this something I do not like , require importing top-level source
code package module in order to reach test code . Say functional test cases
are written for a web product then importing src pkg means that its
dependencies e.g. should be available at run time . This may be actually
useless , because functional test code won use that but instead other
packages like twill , selenium , xmlrpclib ... or any other client lib to
automate interactions with the real instance , rather than the server code
actually implementing those service . That coupling ... /me no likes ;)


>
> 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.
>

agreed .


> Each python package (I go by product1, product2, product3 here) should
> have its own tests directory (sits next to setup.py).
>

You mean like bloodhound_multiproduct above ? That's the layout I prefer .


> If two packages share a lot of test utilities scripts (I call them test
> drivers), consider making those utilities into separate python package.
>
>
+1


> 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.
>
>
ok

[...]

-- 
Regards,

Olemis - @olemislc

Apache(tm) Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:





-- 
Regards,

Olemis - @olemislc

Apache(tm) Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140227/6bdfb2d5/attachment-0001.htm>


More information about the testing-in-python mailing list