diff --git a/CHANGELOG b/CHANGELOG index 3c4f95966..454ad3d1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/ISSUES.txt b/ISSUES.txt index 2f007821c..7127ac3d0 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -1,13 +1,4 @@ -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 @@ -15,19 +6,6 @@ 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 diff --git a/doc/test/plugin/capture.txt b/doc/test/plugin/capture.txt index 93b03b4a4..441d35fdf 100644 --- a/doc/test/plugin/capture.txt +++ b/doc/test/plugin/capture.txt @@ -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 -------------------- diff --git a/doc/test/plugin/hookspec.txt b/doc/test/plugin/hookspec.txt index 0042465f2..c54301402 100644 --- a/doc/test/plugin/hookspec.txt +++ b/doc/test/plugin/hookspec.txt @@ -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): diff --git a/doc/test/plugin/links.txt b/doc/test/plugin/links.txt index 29a77583f..8a7e2a8ae 100644 --- a/doc/test/plugin/links.txt +++ b/doc/test/plugin/links.txt @@ -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 diff --git a/doc/test/plugin/skipping.txt b/doc/test/plugin/skipping.txt index 88e725938..87db94d35 100644 --- a/doc/test/plugin/skipping.txt +++ b/doc/test/plugin/skipping.txt @@ -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. diff --git a/py/plugin/pytest_capture.py b/py/plugin/pytest_capture.py index 78cc57275..4cc1d8297 100644 --- a/py/plugin/pytest_capture.py +++ b/py/plugin/pytest_capture.py @@ -182,6 +182,8 @@ class CaptureManager: 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) @@ -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) diff --git a/testing/plugin/test_pytest_capture.py b/testing/plugin/test_pytest_capture.py index 1ba7c2b72..b928d8b79 100644 --- a/testing/plugin/test_pytest_capture.py +++ b/testing/plugin/test_pytest_capture.py @@ -391,3 +391,16 @@ def test_setup_failure_does_not_kill_capturing(testdir): "*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*" + ]) +