Tags are great for you to selectively control what tests you want to run. But what can you do when you have tests under development that aren't ready for prime time or you have tests that are misbehaving? Nose has a nice plugin that allows you to raise a Skip exception.
Lets say we have the follow five tests:
This will be 'test_one_fish.py:'
def test_one_fish(): print "I'm the one fish test." test_one_fish.tags = ["number", "one"]
This will be 'test_two_fish.py:'
def test_two_fish(): print "I'm the two fish test." test_two_fish.tags = ["number", "two"]
This will be 'test_red_fish.py:'
def test_red_fish(): print "I'm the red fish test." test_red_fish.tags = ["color", "red"]
This will be 'test_blue_fish.py:'
def test_blue_fish(): print "I'm the blue fish test." test_blue_fish.tags = ["color", "blue"]
This will be 'test_new_fish.py:'
from nose.plugins.skip import Skip, SkipTest def test_new_fish(): print "I'm the new fish test." print "OH NOES A FIXME" raise SkipTest test_new_fish.tags = ["string", "new"]
These examples are lifted straight from the tags example, but we've added 'test_new_fish.py.' You should notice in the file that we import Skip and SkipTest from the nose.plugins.skip module, and we also raise a SkipTest exception because we're simulating a test that's in progress or that might be misbehaving. Okay, let's see what nose shoots out (that's kind of gross):
[terryp@tpmacbook] sample_skip :: nosetests .S... ---------------------------------------------------------------------- Ran 5 tests in 0.009s OK (SKIP=1)
Because we've raised a SkipTest, we don't get 5 great little dots, but we get 4 dots and an S representing the skipped test. And because skipped tests aren't failures, the test run itself still passes.
Fluid 960 Grid System, created by Stephen Bau, based on the 960 Grid System by Nathan Smith. Released under the GPL/ MIT Licenses.