tags:

views:

233

answers:

1

I'm trying to write a task for Paver that will run nosetests on my files.

My directory structure looks like this:

project/
   file1.py
   file2.py
   file3.py
   build/
      pavement.py
   subproject/
      file4.py
   test/
      file5.py
      file6.py

Doctests (using the --with_doctest option) should be run on all the *.py files, while only the files under project/test (in this example, file5.py and file6.py) should be searched for test routines.

I can't seem to figure out how to do this--I can write a custom plugin for nose which includes the correct files, but I can't seem to get paver to build and install it before calling the nosetests task. I also can't find a way to get paver to pass a list of files to test to nosetests on the command line.

What's the best way of getting this to work?

+1  A: 

Is this at all close to what you're trying to get at?

from paver.easy import sh, path
__path__ = path(__file__).abspath().dirname()

@task
def setup_nose_plugin():
    # ... do your plugin setup here.

@task
@needs('setup_nose_plugin')
def nosetests():
    nose_options = '--with-doctest' # Put your command-line options in there
    sh('nosetests %s' % nose_options, 
       # Your pavement.py is in a weird place, so you need to specify the working dir:
       cwd=__path__.parent)

I'm not actually sure how to tell nose to look in specific files, but that's a matter of command-line options.

--where lets you specify a directory, but I don't see a way to say "run only doctests here, and other tests here". You may need two invocations of sh('nosetests') to do all that.

David Eyk