[TIP] testing setuptools-related code

Andrea Crotti andrea.crotti.0 at gmail.com
Thu Jan 19 06:44:43 PST 2012


On 01/19/2012 02:35 PM, Andrea Crotti wrote:
> I have (sadly) a special builder/runner that manages eggs and install 
> eggs.
> I've used the -m flag and I use pkg_resources to find the installed 
> software,
> but I didn't find a way to test everything..
>
> So what might be the easiest/portable solution to write some tests 
> that for
> example:
>
> - run the setuptools-based installer with the '-m'
> - try to require it
>
> without interfering with the global environment?

One possible idea (which might come handy also for other purposes) is to use
virtualenv, the problem is that I don't find any example where it's 
actually used from
other python scripts, without an actual shell interaction.

I think something like this would be good:

     virtualenv.create_environment(venv, site_packages=False, clear=False)
     e = Egg(path.join('deps', 'app'))
     e.develop()

But I have to find a way to tell my code to pass to the Popen the 
virtualenv activation,
anyone already did it?



More information about the testing-in-python mailing list