[Distutils] Testing with stubbed entry points?

Iwan Vosloo iv at lantic.net
Thu Feb 23 08:52:29 CET 2006

"Phillip J. Eby" <pje at telecommunity.com> writes:
> At 12:26 PM 2/22/2006 +0200, Iwan Vosloo wrote:
> >What is the easiest way (in testing code) to make a new entry point in
> >some group in a test setup, and nuke it again in the test tearDown?
> Well, there isn't a particularly easy way right now.  You have to
> create a Distribution with a dummy metadata containing
> entry_points.txt, or else you have to subclass Distribution to create
> a mock that returns what you want from the entry point methods.  

Ok, I played with subclassing Distribution, but I think the dummy
metadata approach is easier.

> You then have to add that Distribution to a WorkingSet instance, and
> you need to make your code use that WorkingSet instead of the
> default working_set.  

Why can't I add the Distribution to the default working_set?
And... do I need to .activate() the distribution?

> If you want to take the dummy metadata route, see the setuptools test
> modules, as they have a mock metadata class that you can give the text
> of what metadata files the distribution will seem to have.

Thanks, I'm playing with it now.


More information about the Distutils-SIG mailing list