regen setup.py and docs so that "python3 setup.py build" maybe works if setuptools does

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-09-06 17:17:37 +02:00
parent c8119d89b6
commit 3c3002ccd5
4 changed files with 56 additions and 66 deletions

View File

@ -32,8 +32,8 @@ on tests that wait on reading something from stdin.
You can influence output capturing mechanisms from the command line:: You can influence output capturing mechanisms from the command line::
py.test -s # disable all capturing py.test -s # disable all capturing
py.test --capture=sys # set StringIO() to each of sys.stdout/stderr py.test --capture=sys # replace sys.stdout/stderr with in-mem files
py.test --capture=fd # capture stdout/stderr on Filedescriptors 1/2 py.test --capture=fd # point filedescriptors 1 and 2 to temp file
If you set capturing values in a conftest file like this:: If you set capturing values in a conftest file like this::
@ -46,7 +46,9 @@ sys-level capturing
------------------------------------------ ------------------------------------------
Capturing on 'sys' level means that ``sys.stdout`` and ``sys.stderr`` Capturing on 'sys' level means that ``sys.stdout`` and ``sys.stderr``
will be replaced with StringIO() objects. will be replaced with in-memory files (``py.io.TextIO`` to be precise)
that capture writes and decode non-unicode strings to a unicode object
(using a default, usually, UTF-8, encoding).
FD-level capturing and subprocesses FD-level capturing and subprocesses
------------------------------------------ ------------------------------------------
@ -71,8 +73,9 @@ per-test capturing. Here is an example test function:
.. sourcecode:: python .. sourcecode:: python
def test_myoutput(capsys): def test_myoutput(capsys):
print "hello" print ("hello")
print >>sys.stderr, "world" sys.stderr.write("world
")
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert out == "hello\n" assert out == "hello\n"
assert err == "world\n" assert err == "world\n"

View File

@ -1,38 +1,38 @@
.. _`helpconfig`: helpconfig.html .. _`helpconfig`: helpconfig.html
.. _`terminal`: terminal.html .. _`terminal`: terminal.html
.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_recwarn.py .. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_recwarn.py
.. _`unittest`: unittest.html .. _`unittest`: unittest.html
.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_monkeypatch.py .. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_monkeypatch.py
.. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_keyword.py .. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_keyword.py
.. _`pastebin`: pastebin.html .. _`pastebin`: pastebin.html
.. _`plugins`: index.html .. _`plugins`: index.html
.. _`pytest_capture.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_capture.py .. _`pytest_capture.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_capture.py
.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_doctest.py .. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_doctest.py
.. _`capture`: capture.html .. _`capture`: capture.html
.. _`pytest_nose.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_nose.py .. _`pytest_nose.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_nose.py
.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_restdoc.py .. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_restdoc.py
.. _`xfail`: xfail.html .. _`xfail`: xfail.html
.. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_pastebin.py .. _`pytest_pastebin.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_pastebin.py
.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_figleaf.py .. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_figleaf.py
.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_hooklog.py .. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_hooklog.py
.. _`checkout the py.test development version`: ../../download.html#checkout .. _`checkout the py.test development version`: ../../download.html#checkout
.. _`pytest_helpconfig.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_helpconfig.py .. _`pytest_helpconfig.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_helpconfig.py
.. _`oejskit`: oejskit.html .. _`oejskit`: oejskit.html
.. _`doctest`: doctest.html .. _`doctest`: doctest.html
.. _`get in contact`: ../../contact.html .. _`get in contact`: ../../contact.html
.. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_xfail.py .. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_xfail.py
.. _`figleaf`: figleaf.html .. _`figleaf`: figleaf.html
.. _`customize`: ../customize.html .. _`customize`: ../customize.html
.. _`hooklog`: hooklog.html .. _`hooklog`: hooklog.html
.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_terminal.py .. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_terminal.py
.. _`recwarn`: recwarn.html .. _`recwarn`: recwarn.html
.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_pdb.py .. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_pdb.py
.. _`monkeypatch`: monkeypatch.html .. _`monkeypatch`: monkeypatch.html
.. _`resultlog`: resultlog.html .. _`resultlog`: resultlog.html
.. _`keyword`: keyword.html .. _`keyword`: keyword.html
.. _`restdoc`: restdoc.html .. _`restdoc`: restdoc.html
.. _`django`: django.html .. _`django`: django.html
.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_unittest.py .. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_unittest.py
.. _`nose`: nose.html .. _`nose`: nose.html
.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.0.2/py/test/plugin/pytest_resultlog.py .. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/trunk/py/test/plugin/pytest_resultlog.py
.. _`pdb`: pdb.html .. _`pdb`: pdb.html

View File

@ -10,8 +10,8 @@ safely patch object attributes, dicts and environment variables.
Usage Usage
---------------- ----------------
Use the `monkeypatch funcarg`_ to safely patch environment Use the `monkeypatch funcarg`_ to safely modify or delete environment
variables, object attributes or dictionaries. For example, if you want variables, object attributes or dictionary values. For example, if you want
to set the environment variable ``ENV1`` and patch the to set the environment variable ``ENV1`` and patch the
``os.path.abspath`` function to return a particular value during a test ``os.path.abspath`` function to return a particular value during a test
function execution you can write it down like this: function execution you can write it down like this:
@ -37,6 +37,20 @@ can use this example:
monkeypatch.setenv('PATH', 'x/y', prepend=":") monkeypatch.setenv('PATH', 'x/y', prepend=":")
# x/y will be at the beginning of $PATH # x/y will be at the beginning of $PATH
calling "undo" finalization explicitely
-----------------------------------------
Usually at the end of function execution py.test will invoke
a teardown hook which undoes the changes. If you cannot wait
that long you can also call finalization explicitely::
monkeypatch.undo()
This will undo previous changes. This call consumes the
undo stack. Calling it a second time has no effect.
Within a test you can continue to use the monkeypatch
object, however.
.. _`monkeypatch blog post`: http://tetamap.wordpress.com/2009/03/03/monkeypatching-in-unit-tests-done-right/ .. _`monkeypatch blog post`: http://tetamap.wordpress.com/2009/03/03/monkeypatching-in-unit-tests-done-right/
.. _`monkeypatch funcarg`: .. _`monkeypatch funcarg`:
@ -45,15 +59,22 @@ can use this example:
the 'monkeypatch' test function argument the 'monkeypatch' test function argument
---------------------------------------- ----------------------------------------
The returned ``monkeypatch`` funcarg provides three The returned ``monkeypatch`` funcarg provides these
helper methods to modify objects, dictionaries or os.environ:: helper methods to modify objects, dictionaries or os.environ::
monkeypatch.setattr(obj, name, value) monkeypatch.setattr(obj, name, value)
monkeypatch.delattr(obj, name, raising=True)
monkeypatch.setitem(mapping, name, value) monkeypatch.setitem(mapping, name, value)
monkeypatch.setenv(name, value) monkeypatch.delitem(obj, name, raising=True)
monkeypatch.setenv(name, value, prepend=False)
monkeypatch.delenv(name, value, raising=True)
monkeypatch.syspath_prepend(path)
All such modifications will be undone when the requesting All modifications will be undone when the requesting
test function finished its execution. test function finished its execution. For the ``del``
methods the ``raising`` parameter determines if a
KeyError or AttributeError will be raised if the
deletion has no target.
Start improving this plugin in 30 seconds Start improving this plugin in 30 seconds
========================================= =========================================

View File

@ -23,6 +23,7 @@ For questions please check out http://pylib.org/contact.html
.. _`py.path`: http://pylib.org/path.html .. _`py.path`: http://pylib.org/path.html
.. _`py.code`: http://pylib.org/code.html .. _`py.code`: http://pylib.org/code.html
(c) Holger Krekel and others, 2009
""" """
trunk = 'trunk' trunk = 'trunk'
@ -58,44 +59,25 @@ def main():
'Topic :: Utilities', 'Topic :: Utilities',
'Programming Language :: Python'], 'Programming Language :: Python'],
packages=['py', packages=['py',
'py._testing',
'py.builtin', 'py.builtin',
'py.builtin.testing',
'py.cmdline', 'py.cmdline',
'py.cmdline.testing',
'py.code', 'py.code',
'py.code.testing',
'py.compat', 'py.compat',
'py.compat.testing',
'py.execnet', 'py.execnet',
'py.execnet.script', 'py.execnet.script',
'py.execnet.testing',
'py.io', 'py.io',
'py.io.testing',
'py.log', 'py.log',
'py.log.testing',
'py.path', 'py.path',
'py.path.gateway', 'py.path.gateway',
'py.path.testing',
'py.process', 'py.process',
'py.process.testing',
'py.rest', 'py.rest',
'py.rest.testing',
'py.test', 'py.test',
'py.test.dist', 'py.test.dist',
'py.test.dist.testing',
'py.test.looponfail', 'py.test.looponfail',
'py.test.looponfail.testing',
'py.test.plugin', 'py.test.plugin',
'py.test.testing',
'py.test.testing.import_test.package',
'py.test.web', 'py.test.web',
'py.thread', 'py.thread'],
'py.thread.testing', package_data={'py': ['bin/_findpy.py',
'py.xmlobj',
'py.xmlobj.testing'],
package_data={'py': ['LICENSE',
'bin/_findpy.py',
'bin/env.cmd', 'bin/env.cmd',
'bin/env.py', 'bin/env.py',
'bin/py.cleanup', 'bin/py.cleanup',
@ -114,26 +96,10 @@ def main():
'bin/win32/py.svnwcrevert.cmd', 'bin/win32/py.svnwcrevert.cmd',
'bin/win32/py.test.cmd', 'bin/win32/py.test.cmd',
'bin/win32/py.which.cmd', 'bin/win32/py.which.cmd',
'compat/LICENSE', 'rest/rest.sty.template']},
'compat/testing/test_doctest.txt',
'compat/testing/test_doctest2.txt',
'execnet/NOTES',
'execnet/improve-remote-tracebacks.txt',
'path/gateway/TODO.txt',
'path/notes-svn-quoting.txt',
'path/testing/repotest.dump',
'rest/rest.sty.template',
'rest/testing/data/example.rst2pdfconfig',
'rest/testing/data/example1.dot',
'rest/testing/data/formula.txt',
'rest/testing/data/formula1.txt',
'rest/testing/data/graphviz.txt',
'rest/testing/data/part1.txt',
'rest/testing/data/part2.txt',
'rest/testing/data/tocdepth.rst2pdfconfig']},
zip_safe=False, zip_safe=False,
) )
if __name__ == '__main__': if __name__ == '__main__':
main() main()