[Distutils] unpacking files from and egg only for testing

Alexander Michael lxander.m at gmail.com
Sun May 13 17:57:22 CEST 2007


[brought back on-list (forgot/didn't notice this list doesn't set Reply-To)]

On 5/13/07, Alexander Schmolck <a.schmolck at gmail.com> wrote:
> [did you send this off-list on purpose?]
> "Alexander Michael" <lxander.m at gmail.com> writes:
>
> > I don't think setuptools/pkg_resources/eggs are designed to handle
> > running tests like this after (end-user) installation. There is
> > support for running unittests during development as part of package
> > building. Does the end user *need* to run these tests to determine the
> > correct package configuration for their machine?
>
> No.
>
> > If not, you should probably wrap up the tests into a test suite and use the
> > setuptools test functionality
> > (<http://peak.telecommunity.com/DevCenter/setuptools#test-build-package-and-run-a-unittest-suite>)
>
> I do have a unitest test suite, and I'm also using the test_suite option.
> However that test suite needs to place several, exiting .m files into tempdir
> (and tell matlab about their whereabouts in order to run all the tests, but
> telling matlab is easy). I still don't see a good way do conditionally extract
> stuff from the egg for testing (I don't think ``test_suite`` does that, unless
> I'm missing something). I could obviously encode all these files as a python
> string in the testmodule and then create them manually in the tempdir or
> something similarly horrible -- sort of like a shell archive, but that strikes
> me as suboptimal.

We're getting out of my depth here. But it is my understanding that
the test command adds the source directory to the sys.path, so that
you could acquire undeclared data files the old-fashioned way (i.e.
os.path.join(mypackage.__path__, 'test-mex.c'), although you might be
able to use pkg_resources which is cleaner. Your test would copy the
test data to a tempdir, do its thing, check the result, and clean-up.

> > along with tempfile (<http://docs.python.org/lib/module-tempfile.html>),
> > otherwise I don't think (but could have missed something) that eggs support
> > running arbitrary code at install time to do such configuration (hence
> > Enthought's postinstall extensions). If the latter, perhaps someone else can
> > be of more help.


More information about the Distutils-SIG mailing list