[TIP] unittest.TestCase and tags

Albert-Jan Roskam fomcl at yahoo.com
Fri Apr 18 12:12:35 PDT 2014



> 
> I have a collection of integration tests based on the unittest package.
> I'd like to be able to categorise tests, so I can select what kind of tests
> I want to run. For example, tests reaching local filesystem,
> tests relying on remote database servers, and so on.

from nose.plugins.attrib import attr
import unittest

class Test(unittest.TestCase):
    @attr('database')
    def test_blah(self):
        self.assertTrue(True)

then select the attribute:

$ nosetests -a database


Thanks, didn't know about this ;-)




More information about the testing-in-python mailing list