nose-devs/nose — Issue #95: attrib plugin runs setup_module/teardown_module even when no tests match the expression
Author: jpellerin
Created: 2011-12-14 15:59:05+00:00
State: open

I have this test structure:

tests/
__init__.py
test_foo.py

__init__.py:
------------
import logging
LOG = logging.getLogger(__name__)

def setup_module():
LOG.info('Opening tests2')

def teardown_module():
LOG.info('Closing tests2')

test_foo.py:
------------
from nose.plugins.attrib import attr
from unittest import TestCase
import logging
LOG = logging.getLogger(__name__)

class TestClass(TestCase):

@attr(tags=(1,2))
def test_1(self):
LOG.info('in %s', self.id())

When I call:
$ nosetests -sv -a tags=3 tests/
15:35:21 - INFO [MainThread]: Opening tests2
15:35:21 - INFO [MainThread]: Closing tests2

----------------------------------------------------------------------
Ran 0 tests in 0.003s

OK

No tests have tags==3 (obviously), but the setup_module/teardown_module were still executed.

I expect the context setup/teardown to be executed when *at least* one of the tests matches attrib module's expression.

Google Code Info:
Issue #: 419
Author: jonsibo...@gmail.com
Created On: 2011-05-12T22:40:23.000Z
Closed On: