From 4622c28ffdd10ff3b3e7c9d4c59ab7c0d1284cc3 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 26 Jan 2014 12:44:21 +0100 Subject: [PATCH] setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality --- _pytest/runner.py | 7 +++---- testing/test_runner.py | 14 -------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/_pytest/runner.py b/_pytest/runner.py index 794c0eed1..539248117 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -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): diff --git a/testing/test_runner.py b/testing/test_runner.py index b65f75aea..f9439ac2d 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -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()