setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality

This commit is contained in:
holger krekel 2014-01-26 12:44:21 +01:00
parent 899998cf9c
commit 4622c28ffd
2 changed files with 3 additions and 18 deletions

View File

@ -316,11 +316,10 @@ class SetupState(object):
""" attach a finalizer to the given colitem.
if colitem is None, this will add a finalizer that
is called at the end of teardown_all().
if colitem is a tuple, it will be used as a key
and needs an explicit call to _callfinalizers(key) later on.
"""
assert hasattr(finalizer, '__call__')
#assert colitem in self.stack
assert colitem and not isinstance(colitem, tuple)
assert callable(finalizer)
#assert colitem in self.stack # some unit tests don't setup stack :/
self._finalizers.setdefault(colitem, []).append(finalizer)
def _pop_and_teardown(self):

View File

@ -14,20 +14,6 @@ class TestSetupState:
ss._pop_and_teardown()
assert not l
def test_setup_scope_None(self, testdir):
item = testdir.getitem("def test_func(): pass")
ss = runner.SetupState()
l = [1]
ss.prepare(item)
ss.addfinalizer(l.pop, colitem=None)
assert l
ss._pop_and_teardown()
assert l
ss._pop_and_teardown()
assert l
ss.teardown_all()
assert not l
def test_teardown_exact_stack_empty(self, testdir):
item = testdir.getitem("def test_func(): pass")
ss = runner.SetupState()