[Pytest-commit] commit/pytest: hpk42: fix issue439: clarify that capsys/capfd capture output during

2014-04-07 Thread commits-noreply
1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/c15664850085/
Changeset:   c15664850085
User:hpk42
Date:2014-04-07 13:42:48
Summary: fix issue439: clarify that capsys/capfd capture output during
test execution, not test setup.
Affected #:  1 file

diff -r 393981dc0f1da8a2699ed4c8bc43f3644af592f9 -r 
c15664850085ac1b38d81b5fb3b30cd48c25f2db doc/en/capture.txt
--- a/doc/en/capture.txt
+++ b/doc/en/capture.txt
@@ -84,11 +84,9 @@
 Accessing captured output from a test function
 ---
 
-The :ref:`funcarg mechanism` allows test function a very easy
-way to access the captured output by simply using the names
-``capsys`` or ``capfd`` in the test function signature.  Here
-is an example test function that performs some output related
-checks::
+The ``capsys`` and ``capfd`` fixtures allow to access stdout/stderr
+output created during test execution.  Here is an example test function
+that performs some output related checks::
 
 def test_myoutput(capsys): # or use "capfd" for fd-level
 print ("hello")
@@ -108,8 +106,10 @@
 output streams and also interacts well with pytest's
 own per-test capturing.
 
-If you want to capture on ``fd`` level you can use
+If you want to capture on filedescriptor level you can use
 the ``capfd`` function argument which offers the exact
-same interface.
+same interface but allows to also capture output from
+libraries or subprocesses that directly write to operating
+system level output streams (FD1 and FD2).
 
 .. include:: links.inc

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.
___
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit


[Pytest-commit] commit/pytest: 2 new changesets

2014-04-07 Thread commits-noreply
2 new commits in pytest:

https://bitbucket.org/hpk42/pytest/commits/6a5904c4816c/
Changeset:   6a5904c4816c
Branch:  issue498
User:hpk42
Date:2014-04-07 13:29:57
Summary: fix issue498: if a fixture finalizer fails, make sure that the 
fixture
is still invalidated.
Affected #:  3 files

diff -r 393981dc0f1da8a2699ed4c8bc43f3644af592f9 -r 
6a5904c4816cebd3e146a4277c0ad5021b131753 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 NEXT (2.6)
 ---
 
+- fix issue498: if a fixture finalizer fails, make sure that 
+  the fixture is still invalidated.
+
 - fix issue453: the result of the pytest_assertrepr_compare hook now gets
   it's newlines escaped so that format_exception does not blow up.
 

diff -r 393981dc0f1da8a2699ed4c8bc43f3644af592f9 -r 
6a5904c4816cebd3e146a4277c0ad5021b131753 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1778,13 +1778,15 @@
 self._finalizer.append(finalizer)
 
 def finish(self):
-while self._finalizer:
-func = self._finalizer.pop()
-func()
 try:
-del self.cached_result
-except AttributeError:
-pass
+while self._finalizer:
+func = self._finalizer.pop()
+func()
+finally:
+# even if finalization fails, we invalidate
+# the cached fixture value
+if hasattr(self, "cached_result"):
+del self.cached_result
 
 def execute(self, request):
 # get required arguments and register our own finish()

diff -r 393981dc0f1da8a2699ed4c8bc43f3644af592f9 -r 
6a5904c4816cebd3e146a4277c0ad5021b131753 testing/python/fixture.py
--- a/testing/python/fixture.py
+++ b/testing/python/fixture.py
@@ -2087,6 +2087,35 @@
 "*1 error*",
 ])
 
+def test_issue498_fixture_finalizer_failing(self, testdir):
+testdir.makepyfile("""
+import pytest
[email protected]
+def fix1(request):
+def f():
+raise KeyError
+request.addfinalizer(f) 
+return object()
+
+l = []
+def test_1(fix1):
+l.append(fix1)
+def test_2(fix1):
+l.append(fix1)
+def test_3():
+assert l[0] != l[1]
+""")
+result = testdir.runpytest()
+result.stdout.fnmatch_lines("""
+*ERROR*teardown*test_1*
+*KeyError*
+*ERROR*teardown*test_2*
+*KeyError*
+*3 pass*2 error*
+""")
+
+
+
 def test_setupfunc_missing_funcarg(self, testdir):
 testdir.makepyfile("""
 import pytest


https://bitbucket.org/hpk42/pytest/commits/81ac392651f5/
Changeset:   81ac392651f5
User:RonnyPfannschmidt
Date:2014-04-07 13:51:03
Summary: Merged in hpk42/pytest-hpk/issue498 (pull request #151)

fix issue498: if a fixture finalizer fails, make sure that the fixture
Affected #:  3 files

diff -r c15664850085ac1b38d81b5fb3b30cd48c25f2db -r 
81ac392651f55934e99828e279c38990e76a873e CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 NEXT (2.6)
 ---
 
+- fix issue498: if a fixture finalizer fails, make sure that 
+  the fixture is still invalidated.
+
 - fix issue453: the result of the pytest_assertrepr_compare hook now gets
   it's newlines escaped so that format_exception does not blow up.
 

diff -r c15664850085ac1b38d81b5fb3b30cd48c25f2db -r 
81ac392651f55934e99828e279c38990e76a873e _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1778,13 +1778,15 @@
 self._finalizer.append(finalizer)
 
 def finish(self):
-while self._finalizer:
-func = self._finalizer.pop()
-func()
 try:
-del self.cached_result
-except AttributeError:
-pass
+while self._finalizer:
+func = self._finalizer.pop()
+func()
+finally:
+# even if finalization fails, we invalidate
+# the cached fixture value
+if hasattr(self, "cached_result"):
+del self.cached_result
 
 def execute(self, request):
 # get required arguments and register our own finish()

diff -r c15664850085ac1b38d81b5fb3b30cd48c25f2db -r 
81ac392651f55934e99828e279c38990e76a873e testing/python/fixture.py
--- a/testing/python/fixture.py
+++ b/testing/python/fixture.py
@@ -2087,6 +2087,35 @@
 "*1 error*",
 ])
 
+def test_issue498_fixture_finalizer_failing(self, testdir):
+testdir.makepyfile("""
+import pytest
[email protected]
+def fix1(request):
+def f():
+raise KeyError
+request.addfinalizer(f) 
+return object()
+
+l = []
+