Skip to content

Commit

Permalink
setupstate.addfinalizer(): fix docstring and remove related unit test…
Browse files Browse the repository at this point in the history
… not covering functional reality
  • Loading branch information
hpk42 committed Jan 26, 2014
1 parent 899998c commit 4622c28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
7 changes: 3 additions & 4 deletions _pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,10 @@ def addfinalizer(self, finalizer, colitem):
""" 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):
Expand Down
14 changes: 0 additions & 14 deletions testing/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ def test_setup(self, testdir):
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()
Expand Down

0 comments on commit 4622c28

Please sign in to comment.