[Distutils] [zc.buildout] building a testrunner

Marius Gedminas marius at pov.lt
Thu Jul 24 22:29:19 CEST 2008

On Thu, Jul 24, 2008 at 07:58:30PM +0100, Chris Withers wrote:
> Jim Fulton wrote:
> >
> >Don't know. Must be a windows thing. ;)
> >
> >I tried your buildout -- even on windows :) -- at it worked fine for me. 
> >The test ran find (with a test failure).  I suggest making sure your 
> >Python is clean.
> Well, I just tried this on linux on both python2.4 and python2.5, source 
> built pythons and got very similar results to those on windows.
> (with the testrunner tripping up on stuff in the egg cache)

What does your buildout.cfg look like?

> PS: The buildout.cfg I'm now using is also checked in and the svn path
>     is https://secure.simplistix.co.uk/svn/Simplistix/twiddler/trunk

Ah, I see you anticipated my question.

> I've also attached the bin/test script. It'd be interesting to know if 
> this differs from yours.

And here it is:

> #!/usr/local/bin/python2.4
> import sys
> sys.path[0:0] = [
>   '/home/chris/twiddler',
>   '/home/chris/twiddler/eggs/zope.testing-3.6.0-py2.4.egg',
>   '/home/chris/twiddler/eggs/zope.interface-3.4.1-py2.4-linux-i686.egg',
>   '/home/chris/twiddler/eggs/setuptools-0.6c8-py2.4.egg',
>   '/home/chris/twiddler/eggs/elementtree-1.2.7_20070827_preview-py2.4.egg',
>   ]
> import os
> sys.argv[0] = os.path.abspath(sys.argv[0])
> os.chdir('/home/chris/twiddler/parts/test')
> import zope.testing.testrunner
> if __name__ == '__main__':
>     zope.testing.testrunner.run([
>   '--test-path', '/home/chris/twiddler',

This is Not Good.  You don't want the test runner to look for tests
under /home/chris/twiddler/, which contains the egg cache directly under
it, as well as your Python packages.

People who use an intermediate 'src/' subdir do not get the problem you
stumbled upon.  I think an intermediate directory is a Very Good Idea,

* you want to be able to import 'twiddler', which means
  /home/chris/twiddler/ must be in you sys.path

* you don't want setup.py or bootstrap.py to be in your sys.path, which
  contradicts the above requirement

OTOH if you want to keep your current package layout, you need to
convince zc.recipe.testrunner to use a different --test-path
(specifically, '/home/chris/twiddler/twiddler').  I've no idea how to
achieve this.  I'd choose the other solution (insert a src/ subdir into
my tree, above the twiddler subdir).

>   ])

> The only other thing I can think of: do you maybe have "default user 
> config files" living in ~ that are influencing zope.testing or 
> zc.recipe.testrunner in some way?

You can override the egg cache location in a dotfile in your home.
Power users do that to avoid downloading the same eggs over and over
again for each project they're working on.

Marius Gedminas
Most security experts REALLY believe in firewalls. The expect that, when they
die, arrive at the great firewall in the sky where Saint Peter is running a
default policy of REJECT.
                --- Sander Plomp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20080724/70221b4b/attachment.pgp>

More information about the Distutils-SIG mailing list