[Distutils] RFC: Standard Declaration of tests in eggs
jpellerin at gmail.com
Thu Jan 18 17:26:29 CET 2007
Hello all. I'm the primary author of nose. Michal Kwiatkowski was kind
enough to point me to this thread, and I wanted to chime in with a few
questions and answers. Apologies for pulling things from various parts
of the thread together, I didn't want to send multiple replies all
covering the same ground.
Nose works fine with setuptools in source packages. It provides
nose.collector for use as a test_suite with the test command, and a
nosetests command that uses nose's own testrunner and supports loading
options from setup.cfg. So for today's use I think it works pretty
well. That's the good news. The bad:
> (I'm not sure if nose really works with eggs, though; ScanningLoader will
> discover tests in eggs as long as the source is included, but nose may be
> strictly file-based for all I know. Changing it probably wouldn't be too
> difficult, however.)
There's no explicit egg support and, unlike ScanningLoader, nose uses
naive os and os.path functions to access the filesystem, so I think
I'll need to supply a 2nd loader than uses pkg_resources.
> The loader must support a .loadTestFromName(name, obj) call, where name
> will be an empty string, and obj will be the object specified by a test
> entry point. The return value must be a unittest.TestSuite. And it must
> be possible to call the loader multiple times with different 'obj' values.
This is broken in nose 0.9.x -- I have the logic of loadTestsFromName
backwards, in that it only uses the module argument to determine the
package context of the name to be loaded; if the name is blank and the
module is 'foo' it will try to load tests from 'foo.' Not so good. It
also currently is a generator that yields tests as they are loaded,
rather finding them all and returning a TestSuite -- I don't know
whether that will also be a problem.
And nose currently uses imp.find_module and imp.load_module to import
test modules, since that seemed to be the easiest way to handle the
very common case of multiple test modules with the same name in
different (non-package) directories. I don't know whether those will
work correctly when importing from an egg.
I'm hoping to fix all of these loader problems in the 0.10 series.
I'll make whatever changes will be needed to support loading from eggs
and the final form of this proposal (so long as that doesn't break
anything that works now), but as you can see I'm going to need some
guidance about what I need to do.
More information about the Distutils-SIG