I'm wondering what the preferences are with respect to placement of unit
tests (specifically in python, but general thoughts are good, too)

Here are the possibilities I can think of and some pros & cons:

1. embed in source code
- seems like it would have an unnecessary runtime penalty
- and besides, you might not want to have it in the distribution
- may be "natural" if using a lot of doctest anyway

2. mingle with source code
- probably the easiest but just seems "dirty"
- distribution scripts need to exclude files "test_*.py"

3. tests go in "test/" (or "t/") subdirs in every source dir
- python needs to add parent to search path in order to import the
module under test (a mild annoyance)
- distribution scripts need to exclude subdirs "*/test/"
- test code fairly easy to find when editing source

4. tests go in a parallel tree
- less visible test files discourage unit test use
- test files awkward to load into editor simultaneous w/ source

5. all tests go into one monster dir
- may make it easier to develop testing utilities
- awkward for source module name collisions
- probably harder to get import paths right than #3


I like #3, but can _sorta_ understand people who prefer #4.

 (I guess I could also believe preferences for #2, but
  I have such a bias against it, I'd be fussier looking
  at the arguments for it. Sorry. But, ..?..)

==> Need more opinions, please.

Regards and thanks,
..jim

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to