skip tests using 'capfd' funcarg but not having os.dup. cleanup issues and regen plugin docs.
--HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									ae63605ac0
								
							
						
					
					
						commit
						a15afb5e48
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								ISSUES.txt
								
								
								
								
							
							
						
						
									
										22
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
--------------------
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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*"
 | 
			
		||||
    ])
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue