Nose tester checking all tests except the tag

I am trying to figure out if there is a way to have the nose test runner do all tests except those with a specific tag. It looks like this is possible with attributes, but I don't see if there is a way to do this using tags that are a subset of attributes.

I am currently using tags by calling

nosetests -a tags='tag'

      

my tagged tests looks like this:

@attr(tags=['foo', 'bar', 'baz'])
    def test_some_stuff(self):

      

But if I want to run the whole test except the 'baz' tag, how would I do it?

I have tried expressions like

nosetests -A 'not baz'
nosetests -a '!baz'
nosetests tags='!baz'

      

But they don't seem to affect anything other than attributes. And I don't see an example of excluding tags in the docs: http://nose.readthedocs.org/en/latest/plugins/attrib.html

I would rather not add a new exclusion-only tag to this big test suite I'm working with, and remember to always add a fake exclusion tag.

+3


source to share


1 answer


You need to flatten your tags. The way you specify this means that you have one attribute with a complex list value.

Instead, specify the entire range of tags as direct attributes.



 # coding: utf-8
 from nose.plugins.attrib import attr


 @attr("foo", "bar", "baz")
 def test1():
     print "I'm test1"


 @attr("foo")
 def test_2():
     print "I'm test2"

      

Then it nosetests -a '!bar' /tmp/test.py

works at will.

+5


source







All Articles