From 1349edd3c6d21a40aa9bb21fee038fc2a57e7df9 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 3 Aug 2009 12:16:12 +0200 Subject: [PATCH] rename iocapture to capture, add/remove some missing files --HG-- branch : 1.0.x --- .../plugin => contrib}/pytest_resultdb.py | 0 .../plugin/{iocapture.txt => capture.txt} | 8 ++-- doc/test/plugin/index.txt | 2 +- doc/test/plugin/links.txt | 34 +++++++------- doc/test/plugin/pastebin.txt | 46 +++++++++++++++++++ doc/test/plugin/pocoo.txt | 0 makepluginlist.py | 2 +- py/test/defaultconftest.py | 2 +- ...{pytest_iocapture.py => pytest_capture.py} | 0 ...st_iocapture.py => test_pytest_capture.py} | 35 +++++++++++--- py/test/plugin/test_pytest_runner.py | 18 -------- 11 files changed, 98 insertions(+), 49 deletions(-) rename {py/test/plugin => contrib}/pytest_resultdb.py (100%) rename doc/test/plugin/{iocapture.txt => capture.txt} (95%) create mode 100644 doc/test/plugin/pastebin.txt delete mode 100644 doc/test/plugin/pocoo.txt rename py/test/plugin/{pytest_iocapture.py => pytest_capture.py} (100%) rename py/test/plugin/{test_pytest_iocapture.py => test_pytest_capture.py} (91%) diff --git a/py/test/plugin/pytest_resultdb.py b/contrib/pytest_resultdb.py similarity index 100% rename from py/test/plugin/pytest_resultdb.py rename to contrib/pytest_resultdb.py diff --git a/doc/test/plugin/iocapture.txt b/doc/test/plugin/capture.txt similarity index 95% rename from doc/test/plugin/iocapture.txt rename to doc/test/plugin/capture.txt index 8639a3711..39d44cc16 100644 --- a/doc/test/plugin/iocapture.txt +++ b/doc/test/plugin/capture.txt @@ -1,6 +1,6 @@ -pytest_iocapture plugin -======================= +pytest_capture plugin +===================== configurable per-test stdout/stderr capturing mechanisms. @@ -122,8 +122,8 @@ Start improving this plugin in 30 seconds Do you find the above documentation or the plugin itself lacking? -1. Download `pytest_iocapture.py`_ plugin source code -2. put it somewhere as ``pytest_iocapture.py`` into your import path +1. Download `pytest_capture.py`_ plugin source code +2. put it somewhere as ``pytest_capture.py`` into your import path 3. a subsequent ``py.test`` run will use your local version Further information: extend_ documentation, other plugins_ or contact_. diff --git a/doc/test/plugin/index.txt b/doc/test/plugin/index.txt index d1ba3ea7e..2eb199651 100644 --- a/doc/test/plugin/index.txt +++ b/doc/test/plugin/index.txt @@ -8,7 +8,7 @@ figleaf_ write and report coverage data with 'figleaf'. monkeypatch_ safely patch object attributes, dicts and environment variables. -iocapture_ configurable per-test stdout/stderr capturing mechanisms. +capture_ configurable per-test stdout/stderr capturing mechanisms. recwarn_ helpers for asserting deprecation and other warnings. diff --git a/doc/test/plugin/links.txt b/doc/test/plugin/links.txt index b43aac69d..3933afaf3 100644 --- a/doc/test/plugin/links.txt +++ b/doc/test/plugin/links.txt @@ -1,33 +1,33 @@ -.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_recwarn.py -.. _`pytest_iocapture.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_iocapture.py -.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_monkeypatch.py -.. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_keyword.py +.. _`terminal`: terminal.html +.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_recwarn.py +.. _`unittest`: unittest.html +.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_monkeypatch.py +.. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_keyword.py .. _`pastebin`: pastebin.html .. _`plugins`: index.html -.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_doctest.py -.. _`terminal`: terminal.html +.. _`pytest_capture.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_capture.py +.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_doctest.py +.. _`capture`: capture.html .. _`hooklog`: hooklog.html -.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_restdoc.py -.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_hooklog.py -.. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_pastebin.py -.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_figleaf.py +.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_restdoc.py +.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_hooklog.py +.. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_pastebin.py +.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_figleaf.py .. _`xfail`: xfail.html .. _`contact`: ../../contact.html .. _`checkout the py.test development version`: ../../download.html#checkout .. _`oejskit`: oejskit.html -.. _`unittest`: unittest.html -.. _`iocapture`: iocapture.html -.. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_xfail.py +.. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_xfail.py .. _`figleaf`: figleaf.html .. _`extend`: ../extend.html -.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_terminal.py +.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_terminal.py .. _`recwarn`: recwarn.html -.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_pdb.py +.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_pdb.py .. _`monkeypatch`: monkeypatch.html .. _`resultlog`: resultlog.html .. _`keyword`: keyword.html .. _`restdoc`: restdoc.html -.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_unittest.py +.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_unittest.py .. _`doctest`: doctest.html -.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/6f105e72c160bd25ad7bbd4d30b1e4e92f275939/py/test/plugin/pytest_resultlog.py +.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/e9bce7c38c26d789a83bc0e9db7c4b8366e44cc1/py/test/plugin/pytest_resultlog.py .. _`pdb`: pdb.html diff --git a/doc/test/plugin/pastebin.txt b/doc/test/plugin/pastebin.txt new file mode 100644 index 000000000..ffbd125ae --- /dev/null +++ b/doc/test/plugin/pastebin.txt @@ -0,0 +1,46 @@ + +pytest_pastebin plugin +====================== + +submit failure or test session information to a pastebin service. + +.. contents:: + :local: + +Usage +---------- + +**Creating a URL for each test failure**:: + + py.test --pastebin=failed + +This will submit full failure information to a remote Paste service and +provide a URL for each failure. You may select tests as usual or add +for example ``-x`` if you only want to send one particular failure. + +**Creating a URL for a whole test session log**:: + + py.test --pastebin=all + +Currently only pasting to the http://paste.pocoo.org service is implemented. + +command line options +-------------------- + + +``--pastebin=mode`` + send failed|all info to Pocoo pastebin service. + +Start improving this plugin in 30 seconds +========================================= + + +Do you find the above documentation or the plugin itself lacking? + +1. Download `pytest_pastebin.py`_ plugin source code +2. put it somewhere as ``pytest_pastebin.py`` into your import path +3. a subsequent ``py.test`` run will use your local version + +Further information: extend_ documentation, other plugins_ or contact_. + +.. include:: links.txt diff --git a/doc/test/plugin/pocoo.txt b/doc/test/plugin/pocoo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/makepluginlist.py b/makepluginlist.py index 1b355e0f1..d220238a9 100644 --- a/makepluginlist.py +++ b/makepluginlist.py @@ -5,7 +5,7 @@ WIDTH = 75 plugins = [ ('Plugins related to Python test functions and programs', - 'xfail figleaf monkeypatch iocapture recwarn',), + 'xfail figleaf monkeypatch capture recwarn',), ('Plugins for other testing styles and languages', 'unittest doctest oejskit restdoc'), ('Plugins for generic reporting and failure logging', diff --git a/py/test/defaultconftest.py b/py/test/defaultconftest.py index 6c39d859e..506935541 100644 --- a/py/test/defaultconftest.py +++ b/py/test/defaultconftest.py @@ -10,6 +10,6 @@ Generator = py.test.collect.Generator Function = py.test.collect.Function Instance = py.test.collect.Instance -pytest_plugins = "default runner iocapture terminal keyword xfail tmpdir execnetcleanup monkeypatch recwarn pdb pastebin unittest".split() +pytest_plugins = "default runner capture terminal keyword xfail tmpdir execnetcleanup monkeypatch recwarn pdb pastebin unittest".split() conf_capture = "fd" diff --git a/py/test/plugin/pytest_iocapture.py b/py/test/plugin/pytest_capture.py similarity index 100% rename from py/test/plugin/pytest_iocapture.py rename to py/test/plugin/pytest_capture.py diff --git a/py/test/plugin/test_pytest_iocapture.py b/py/test/plugin/test_pytest_capture.py similarity index 91% rename from py/test/plugin/test_pytest_iocapture.py rename to py/test/plugin/test_pytest_capture.py index 5156f707c..cc81b2664 100644 --- a/py/test/plugin/test_pytest_iocapture.py +++ b/py/test/plugin/test_pytest_capture.py @@ -1,5 +1,5 @@ import py, os, sys -from py.__.test.plugin.pytest_iocapture import CaptureManager +from py.__.test.plugin.pytest_capture import CaptureManager class TestCaptureManager: @@ -88,6 +88,31 @@ class TestPerTestCapturing: "in func2*", ]) + @py.test.mark.xfail + def test_capture_scope_cache(self, testdir): + p = testdir.makepyfile(""" + import sys + def setup_module(func): + print "module-setup" + def setup_function(func): + print "function-setup" + def test_func(): + print "in function" + assert 0 + def teardown_function(func): + print "in teardown" + """) + result = testdir.runpytest(p) + result.stdout.fnmatch_lines([ + "*test_func():*", + "*Captured stdout during setup*", + "module-setup*", + "function-setup*", + "*Captured stdout*", + "in teardown*", + ]) + + def test_no_carry_over(self, testdir): p = testdir.makepyfile(""" def test_func1(): @@ -230,9 +255,7 @@ class TestLoggingInteraction: # verify proper termination assert "closed" not in s - @py.test.mark.xfail def test_logging_and_crossscope_fixtures(self, testdir): - # XXX also needs final teardown reporting to work! p = testdir.makepyfile(""" import logging def setup_module(function): @@ -246,14 +269,14 @@ class TestLoggingInteraction: logging.warn("hello3") assert 0 """) - for optargs in (('--iocapture=sys',), ('--iocapture=fd',)): + for optargs in (('--capture=sys',), ('--capture=fd',)): print optargs result = testdir.runpytest(p, *optargs) s = result.stdout.str() result.stdout.fnmatch_lines([ + "*WARN*hello3", # errors come first "*WARN*hello1", "*WARN*hello2", - "*WARN*hello3", ]) # verify proper termination assert "closed" not in s @@ -303,5 +326,3 @@ class TestCaptureFuncarg: ]) assert result.ret == 2 - - diff --git a/py/test/plugin/test_pytest_runner.py b/py/test/plugin/test_pytest_runner.py index 4b279d56b..f4fcc239b 100644 --- a/py/test/plugin/test_pytest_runner.py +++ b/py/test/plugin/test_pytest_runner.py @@ -193,24 +193,6 @@ class BaseFunctionalTests: else: py.test.fail("did not raise") - @py.test.mark.xfail - def test_capture_per_func(self, testdir): - reports = testdir.runitem(""" - import sys - def setup_function(func): - print "in setup" - def test_func(): - print "in function" - assert 0 - def teardown_function(func): - print "in teardown" - """) - assert reports[0].outerr[0] == "in setup\n" - assert reports[1].outerr[0] == "in function\n" - assert reports[2].outerr[0] == "in teardown\n" - - - class TestExecutionNonForked(BaseFunctionalTests): def getrunner(self): def f(item):