Skip to content

Commit 4622c28

Browse files
committed
setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality
1 parent 899998c commit 4622c28

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

_pytest/runner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,10 @@ def addfinalizer(self, finalizer, colitem):
316316
""" attach a finalizer to the given colitem.
317317
if colitem is None, this will add a finalizer that
318318
is called at the end of teardown_all().
319-
if colitem is a tuple, it will be used as a key
320-
and needs an explicit call to _callfinalizers(key) later on.
321319
"""
322-
assert hasattr(finalizer, '__call__')
323-
#assert colitem in self.stack
320+
assert colitem and not isinstance(colitem, tuple)
321+
assert callable(finalizer)
322+
#assert colitem in self.stack # some unit tests don't setup stack :/
324323
self._finalizers.setdefault(colitem, []).append(finalizer)
325324

326325
def _pop_and_teardown(self):

testing/test_runner.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,6 @@ def test_setup(self, testdir):
1414
ss._pop_and_teardown()
1515
assert not l
1616

17-
def test_setup_scope_None(self, testdir):
18-
item = testdir.getitem("def test_func(): pass")
19-
ss = runner.SetupState()
20-
l = [1]
21-
ss.prepare(item)
22-
ss.addfinalizer(l.pop, colitem=None)
23-
assert l
24-
ss._pop_and_teardown()
25-
assert l
26-
ss._pop_and_teardown()
27-
assert l
28-
ss.teardown_all()
29-
assert not l
30-
3117
def test_teardown_exact_stack_empty(self, testdir):
3218
item = testdir.getitem("def test_func(): pass")
3319
ss = runner.SetupState()

0 commit comments

Comments
 (0)