[Pytest-commit] commit/pytest: hpk42: setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Jan 26 12:44:29 CET 2014


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/5105e627d98d/
Changeset:   5105e627d98d
User:        hpk42
Date:        2014-01-26 12:44:21
Summary:     setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality
Affected #:  2 files

diff -r 4f3a783d4b7afc276205d7dd3247ee91f8722a34 -r 5105e627d98de316ef9d414b5236e1a18e78c304 _pytest/runner.py
--- a/_pytest/runner.py
+++ b/_pytest/runner.py
@@ -316,11 +316,10 @@
         """ 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 -r 4f3a783d4b7afc276205d7dd3247ee91f8722a34 -r 5105e627d98de316ef9d414b5236e1a18e78c304 testing/test_runner.py
--- a/testing/test_runner.py
+++ b/testing/test_runner.py
@@ -14,20 +14,6 @@
         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()

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list