[Zope3-dev] Package organization quandry

Patrick K. O'Brien pobrien@orbtech.com
Fri, 17 May 2002 12:38:19 -0500


[Barry A. Warsaw]
>
> +10 back 'atcha!

Cool. Now we have enough members to form our own mutual admiration society.
<wink>

> BTW, I think we need to make some minor changes to distutils to make
> this really convenient, but then again, who knows what Greg's got
> hiding in distutils. :)
>
> Specifically, I want the setup.py to live in the directory with the
> source code, not in a parent directory.

That's how I've done it so far. Works for me.

> I also think we can do a little bit better to provide standard test
> scripts that fiddle with sys.path for you, and possibly tie distutils
> and unittest together so that you can distutils install, run, and test
> from the unpack directory.

Here is a gimmick I'm using in a "unit test skeleton" code generating
utility I'm working on that creates the skeleton of a unit test module for
an existing python module. The new unit test module always goes into a
subdirectory below the module to be tested, so the following trick works no
matter what the python path might be:

# Import the module from the parent of this module's directory.
import os
import sys
sys.path.insert(0, os.pardir)
import module_to_be_tested
del sys.path[0]
del sys
del os

FYI, the utility can be found here and is working, but I plan to add some
more features and try it out on some of the standard library modules that
are lacking unit tests.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/orbtech/Orbtech/TestUtil/test
gen.py

---
Patrick K. O'Brien
Orbtech