[Python-il] Where to put tests
cool-rr at cool-rr.com
Tue Sep 7 23:24:44 IDT 2010
You're right about the importing problem, I didn't think about that, so I'll
use a suffix of "_test.py" instead.
On Tue, Sep 7, 2010 at 10:31 AM, Ori Peleg <oripel at gmail.com> wrote:
> In my experience both solutions work. I've heard and read considerable
> debate about the two approaches but it tends to boils down to non-technical
> In your case, having the tests next to the modules sounds very convenient.
> A dot in the filename can be tricky (importing, for example) but a
> different suffix or prefix should be fine.
> Another layout, which works better with a flatter directory tree than
> yours, is to have a 'tests/' subdirectory in each package.
> On Tue, Sep 7, 2010 at 12:28 AM, cool-RR <cool-rr at cool-rr.com> wrote:
>> Hello guys!
>> I'm still new to the whole testing thing. There's something that I've been
>> thinking about and maybe you'll have an idea.
>> For my project GarlicSim I created a few tests modules, which I put in a
>> "tests" directory alongside the "garlicsim" directory. This arrangement
>> works, but it kind of bothers me, because in `garlicsim` I have a deep tree
>> of packages; Python packages inside Python packages inside Python packages
>> What's bothering me is this: What happens if I want to write a test for a
>> module which is deep in the hierarchy of the project? I mean, I wouldn't
>> want to put all my tests in one directory, because there will be so many
>> tests, ideally one for each module, and I have ~300 modules. So I'll
>> probably want the tests to be arranged in a tree structure similar to the
>> code itself. But then I thought, why bother with a "tests" directory at all?
>> Maybe instead of a "tests" directory, I'll just put the test for each module
>> alongside that module? I figured maybe I can give the test modules names
>> that end in ".test.py" so it will be easy to tell the difference between
>> test modules and normal modules.
>> Do you think this solution can work? Any problems I didn't think about?
>> Any other ideas that might be helpful?
>> Best Wishes,
>> Python-il mailing list
>> Python-il at hamakor.org.il
> Check out my blog: http://orip.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-il