Skip to content

Commit

Permalink
skip tests using 'capfd' funcarg but not having os.dup. cleanup issue…
Browse files Browse the repository at this point in the history
…s and regen plugin docs.

--HG--
branch : trunk
  • Loading branch information
hpk42 committed Dec 30, 2009
1 parent ae63605 commit a15afb5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Changes between 1.X and 1.1.1

- new "pytestconfig" funcarg allows access to test config object

- automatically skip tests that need 'capfd' but have no os.dup

- allow pytest_generate_tests to be defined in classes as well

- collection/item node specific runtest/collect hooks are only called exactly
Expand Down
22 changes: 0 additions & 22 deletions ISSUES.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@

consider conftest hooks only for items below the dir
---------------------------------------------------------
tags: bug 1.1.2

currently conftest hooks remain registered throughout
the whole testing process. Consider to only have them
called if their filesystem location is below a test item.


introduce py.test.mark.nocollect
-------------------------------------------------------
tags: feature

for not considering a function for test collection at all.
maybe also introduce a py.test.mark.test to explicitely
mark a function to become a tested one. Lookup
Java JUnit recent strategies/syntax.

capture plugin: skip on missing os.dup for 'capfd'
--------------------------------------------------------

tags: feature

Currrently for Jython one needs do an explicit skip like this:

@py.test.mark.skipif("not hasattr(os, 'dup')")

to avoid a failure when 'capfd' is used. Instead
provide an automatic skip.


have imported module mismatch honour relative paths
Expand Down
4 changes: 3 additions & 1 deletion doc/test/plugin/capture.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ the 'capfd' test function argument

captures writes to file descriptors 1 and 2 and makes
snapshotted ``(out, err)`` string tuples available
via the ``capsys.readouterr()`` method.
via the ``capsys.readouterr()`` method. If the underlying
platform does not have ``os.dup`` (e.g. Jython) tests using
this funcarg will automatically skip.

command line options
--------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/test/plugin/hookspec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ hook specification sourcecode
# error handling and internal debugging hooks
# -------------------------------------------------------------------------

def pytest_plugin_registered(plugin):
def pytest_plugin_registered(plugin, manager):
""" a new py lib plugin got registered. """

def pytest_plugin_unregistered(plugin):
Expand Down
34 changes: 17 additions & 17 deletions doc/test/plugin/links.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
.. _`helpconfig`: helpconfig.html
.. _`terminal`: terminal.html
.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_recwarn.py
.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_recwarn.py
.. _`unittest`: unittest.html
.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_monkeypatch.py
.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_monkeypatch.py
.. _`pastebin`: pastebin.html
.. _`skipping`: skipping.html
.. _`plugins`: index.html
.. _`mark`: mark.html
.. _`tmpdir`: tmpdir.html
.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_doctest.py
.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_doctest.py
.. _`capture`: capture.html
.. _`pytest_nose.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_nose.py
.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_restdoc.py
.. _`pytest_nose.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_nose.py
.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_restdoc.py
.. _`restdoc`: restdoc.html
.. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_pastebin.py
.. _`pytest_tmpdir.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_tmpdir.py
.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_figleaf.py
.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_hooklog.py
.. _`pytest_skipping.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_skipping.py
.. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_pastebin.py
.. _`pytest_tmpdir.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_tmpdir.py
.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_figleaf.py
.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_hooklog.py
.. _`pytest_skipping.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_skipping.py
.. _`checkout the py.test development version`: ../../install.html#checkout
.. _`pytest_helpconfig.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_helpconfig.py
.. _`pytest_helpconfig.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_helpconfig.py
.. _`oejskit`: oejskit.html
.. _`doctest`: doctest.html
.. _`pytest_mark.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_mark.py
.. _`pytest_mark.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_mark.py
.. _`get in contact`: ../../contact.html
.. _`pytest_capture.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_capture.py
.. _`pytest_capture.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_capture.py
.. _`figleaf`: figleaf.html
.. _`customize`: ../customize.html
.. _`hooklog`: hooklog.html
.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_terminal.py
.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_terminal.py
.. _`recwarn`: recwarn.html
.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_pdb.py
.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_pdb.py
.. _`monkeypatch`: monkeypatch.html
.. _`coverage`: coverage.html
.. _`resultlog`: resultlog.html
.. _`django`: django.html
.. _`xmlresult`: xmlresult.html
.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_unittest.py
.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_unittest.py
.. _`nose`: nose.html
.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1/py/plugin/pytest_resultlog.py
.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.1.1post1/py/plugin/pytest_resultlog.py
.. _`pdb`: pdb.html
2 changes: 1 addition & 1 deletion doc/test/plugin/skipping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ advanced skipping for python test functions, classes or modules.

With this plugin you can mark test functions for conditional skipping
or as "xfail", expected-to-fail. Skipping a test will avoid running it
at all while xfail-marked tests will run and result in an inverted outcome:
while xfail-marked tests will run and result in an inverted outcome:
a pass becomes a failure and a fail becomes a semi-passing one.

The need for skipping a test is usually connected to a condition.
Expand Down
6 changes: 5 additions & 1 deletion py/plugin/pytest_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def activate_funcargs(self, pyfuncitem):
assert not hasattr(self, '_capturing_funcargs')
l = []
for name, obj in pyfuncitem.funcargs.items():
if name == 'capfd' and not hasattr(os, 'dup'):
py.test.skip("capfd funcarg needs os.dup")
if name in ('capsys', 'capfd'):
obj._start()
l.append(obj)
Expand Down Expand Up @@ -250,7 +252,9 @@ def pytest_funcarg__capsys(request):
def pytest_funcarg__capfd(request):
"""captures writes to file descriptors 1 and 2 and makes
snapshotted ``(out, err)`` string tuples available
via the ``capsys.readouterr()`` method.
via the ``capsys.readouterr()`` method. If the underlying
platform does not have ``os.dup`` (e.g. Jython) tests using
this funcarg will automatically skip.
"""
return CaptureFuncarg(request, py.io.StdCaptureFD)

Expand Down
13 changes: 13 additions & 0 deletions testing/plugin/test_pytest_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,16 @@ def pytest_runtest_setup(item):
"*ValueError(42)*",
"*1 error*"
])

def test_fdfuncarg_skips_on_no_osdup(testdir):
testdir.makepyfile("""
import os
del os.dup
def test_hello(capfd):
pass
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines([
"*1 skipped*"
])

0 comments on commit a15afb5

Please sign in to comment.