[Tutor] directory structure with tests?

2019-03-06 Thread James Hartley
It is preferable to sprinkle tests files throughout the directories of a
project, or coalesce all tests in a test directory?

Thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] directory structure with tests?

2019-03-06 Thread Mats Wichmann
On 3/6/19 3:17 PM, James Hartley wrote:
> It is preferable to sprinkle tests files throughout the directories of a
> project, or coalesce all tests in a test directory?

"It depends".

There are people who have strong opinions.

If you're going to use conventions like naming the test for the
functionality in foo.py as test_foo.py, it makes sense for the two to be
nearby each other. That can be the same directory, or a subdirectory (a
harness like Py.Test will find files named test_* and assume they're
tests whichever place they're in). Very large projects may well split
tests into more subdirectories based on their purpose or usage.

On the other hand, if your project is going to be turned into a package,
you might want to keep the tests in a separate directory, as it may be
somewhat easier to select what goes into the package if they're not
sprinkled together.

You may also end up handling unit tests and integration tests differently.

How's that for a definitive answer?  :)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] directory structure with tests?

2019-03-06 Thread Alan Gauld via Tutor
On 06/03/2019 22:38, Mats Wichmann wrote:

> "It depends".
...
> How's that for a definitive answer?  :)

Pretty good! and I agree with all of it :-)

Although  personally I always use a test subdirectory
and then, for building a distributable, use a file
filter (eg find in *nix) to prune those out.
All version controlled of course!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] directory structure with tests?

2019-03-06 Thread Cameron Simpson

On 06Mar2019 23:41, Alan Gauld  wrote:

On 06/03/2019 22:38, Mats Wichmann wrote:

"It depends".

...

How's that for a definitive answer?  :)


Pretty good! and I agree with all of it :-)

Although  personally I always use a test subdirectory
and then, for building a distributable, use a file
filter (eg find in *nix) to prune those out.
All version controlled of course!


There are those who argue that it is better to include the test files in 
the distribution. Aside from transparency and completeness, it may also 
aid bug reports as a test might only fail in the end user's environment 
and not that of the developer. Being able to get the error output from 
the end user running the tests is a win there.


Q: How many user support people does it take to change a light bulb?
A: We have an exact copy of the light bulb here and it seems to be
  working fine.  Can you tell me what kind of system you have?

For variety, in my own code I keep the tests for foo.py in foo_tests.py, 
the better to be seen next to foo.py in listings and file completion.


Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor