[TIP] nose programmatically & subset of tests?

Ringo De Smet ringo.desmet at gmail.com
Mon Mar 22 00:12:06 PDT 2010


Hello,

On 19 March 2010 15:11, Ringo De Smet <ringo.desmet at gmail.com> wrote:
>
> I am using nose inside another Python application where I expose test
> functionality. I first experimented with the nosetests command line
> script to find out about the various arguments. I wants to find all
> tests in a certain folder (not the current working directory) and run
> either all or a subset of the tests. With nosetests, I was able to
> perform this with:
>
> all tests: nosetests --where /opt/qbase3/var/tests --verbosity 4
> subset of tests: nosetests --where /opt/qbase3/var/tests --verbosity 4
> volume_driver
>
> Taking the same set of options and passing that on to nose.run() as
> the argv list doesn't give me the same behaviour:

I found it. The culprit was on the following line from nose:

return parser.parseArgsAndConfigFiles(argv[1:], cfg_files)

http://code.google.com/p/python-nose/source/browse/nose/config.py#261

When you pass an argv, the first element in the list is dropped. From
the command line, the first argument is the nosetests script, but when
passing it programmatically, I only passed in the real arguments. In
my case, the "--where" option was dropped, taking the folder location
and the module as 2 paths to run tests from.

Either this is a bug or expected. If it is expected, it should be
documented more thoroughly.

Greetings,

Ringo



More information about the testing-in-python mailing list