setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality
This commit is contained in:
parent
899998cf9c
commit
4622c28ffd
|
@ -316,11 +316,10 @@ class SetupState(object):
|
||||||
""" attach a finalizer to the given colitem.
|
""" attach a finalizer to the given colitem.
|
||||||
if colitem is None, this will add a finalizer that
|
if colitem is None, this will add a finalizer that
|
||||||
is called at the end of teardown_all().
|
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 and not isinstance(colitem, tuple)
|
||||||
#assert colitem in self.stack
|
assert callable(finalizer)
|
||||||
|
#assert colitem in self.stack # some unit tests don't setup stack :/
|
||||||
self._finalizers.setdefault(colitem, []).append(finalizer)
|
self._finalizers.setdefault(colitem, []).append(finalizer)
|
||||||
|
|
||||||
def _pop_and_teardown(self):
|
def _pop_and_teardown(self):
|
||||||
|
|
|
@ -14,20 +14,6 @@ class TestSetupState:
|
||||||
ss._pop_and_teardown()
|
ss._pop_and_teardown()
|
||||||
assert not l
|
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):
|
def test_teardown_exact_stack_empty(self, testdir):
|
||||||
item = testdir.getitem("def test_func(): pass")
|
item = testdir.getitem("def test_func(): pass")
|
||||||
ss = runner.SetupState()
|
ss = runner.SetupState()
|
||||||
|
|
Loading…
Reference in New Issue