[TIP] Extension module discovery questions...
jpellerin at gmail.com
Wed Jun 25 07:27:56 PDT 2008
On Tue, Jun 24, 2008 at 8:54 PM, Fernando Perez <fperez.net at gmail.com> wrote:
> Hi all,
> me again :) Sorry if this is getting annoying but I'm a bit lost
> after reading the docs and trying lots of different things.
> The issue I have is exactly how to tweak nose to support the discovery
> of extension modules in a package.
Here's what I would do:
* save a reference to the core test loader in prepareTestLoader()
* implement wantFile() to return True for files that are extension modules
* implement loadTestsFromFile() so that when it sees a file that is an
extension module, it imports the module and then does:
(if you just return rather than yielding there, you'll lose the
ability to have context fixtures in the extension module. If that's
ok, you can just return
> With my monkeypatched plugin, I can get the following line to work OK:
> nosetests -s --with-ipdoctest --doctest-tests sprimes sprimes.primes
Yup, by doing that you're directing nose to load from entities with
those names. Since the name sprimes.primes looks like a module, nose
imports it (without knowing it's an extension module) and passes it
through to loadTestsFromModule(). The process I outlined above should
get you to the same place automatically.
More information about the testing-in-python