[Distutils] testing with eggs

Ian Bicking ianb at colorstudy.com
Sat Aug 20 05:04:16 CEST 2005

Phillip J. Eby wrote:
> At 06:00 PM 8/19/2005 -0500, Ian Bicking wrote:
>> Just thought I'd pass this along, since it took me a little while to
>> figure it out.  Maybe this can go in docs somewhere, but I'm not sure 
>> where.
>> So, I'm writing some code that uses egg plugins, and thus I need testing
>> eggs.  These need to be path-independent (since the checkouts might live
>> anywhere), with no setup commands (you shouldn't have to install the
>> testing version of the eggs to run the tests), and the eggs should be
>> available only when you are running the tests (no global installation).
> I'm kind of confused.  Maybe what you want is to create dummy 
> Distribution objects and add them to a WorkingSet, then use the 
> WorkingSet's APIs in your tests (such as iter_entry_points, require(), 
> etc.).  It's not entirely clear to me what it is that you're testing, so 
> I'm not sure.

I'm testing loading WSGI apps out of eggs using entry points.  So there 
will be real code in those test packages, though just stubby code.  I'm 
not testing setuptools per se, so dummy Distributions probably won't be 
of much use.

>> At first I tried adding fake_packages to sys.path; didn't work at all.
> Because the subdirectories' names don't end in .egg; if they did and you 
> just used EGG-INFO instead of .egg-info, it would work.

OK, I'll try that.  I was surprised, though, that FakeApp.egg-link 
didn't work until I added the directory as addsitedir.  Though I was 
flailing about to get it working, so I don't know what exactly 
combination of things I ended up using.

I also realize it would be nice to refresh the egg_info before running 
the tests, but I'm not sure how well that will work if it happens in the 
same process as the tests themselves.  Or how I run a setup() command 
from Python.

Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org

More information about the Distutils-SIG mailing list