add some docs and new projects
This commit is contained in:
parent
96a687b97c
commit
752965c298
|
@ -12,6 +12,47 @@ attempts to read from it. This is important if some code paths in
|
||||||
test otherwise might lead to waiting for input - which is usually
|
test otherwise might lead to waiting for input - which is usually
|
||||||
not desired when running automated tests.
|
not desired when running automated tests.
|
||||||
|
|
||||||
|
.. _printdebugging:
|
||||||
|
|
||||||
|
Using print statements for debugging
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
One primary benefit of the default capturing of stdout/stderr output
|
||||||
|
is that you can use print statements for debugging::
|
||||||
|
|
||||||
|
# content of test_module.py
|
||||||
|
|
||||||
|
def setup_function(function):
|
||||||
|
print ("setting up %s" % function)
|
||||||
|
|
||||||
|
def test_func1():
|
||||||
|
assert True
|
||||||
|
|
||||||
|
def test_func2():
|
||||||
|
assert False
|
||||||
|
|
||||||
|
and running this module will show you precisely the output
|
||||||
|
of the failing function and hide the other one::
|
||||||
|
|
||||||
|
$ py.test
|
||||||
|
=========================== test session starts ============================
|
||||||
|
platform linux2 -- Python 2.6.5 -- pytest-2.0.1.dev1
|
||||||
|
collecting ... collected 2 items
|
||||||
|
|
||||||
|
test_module.py .F
|
||||||
|
|
||||||
|
================================= FAILURES =================================
|
||||||
|
________________________________ test_func2 ________________________________
|
||||||
|
|
||||||
|
def test_func2():
|
||||||
|
> assert False
|
||||||
|
E assert False
|
||||||
|
|
||||||
|
test_module.py:9: AssertionError
|
||||||
|
----------------------------- Captured stdout ------------------------------
|
||||||
|
setting up <function test_func2 at 0x1e6cd70>
|
||||||
|
==================== 1 failed, 1 passed in 0.04 seconds ====================
|
||||||
|
|
||||||
Setting capturing methods or disabling capturing
|
Setting capturing methods or disabling capturing
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
|
@ -35,14 +76,6 @@ You can influence output capturing mechanisms from the command line::
|
||||||
py.test --capture=sys # replace sys.stdout/stderr with in-mem files
|
py.test --capture=sys # replace sys.stdout/stderr with in-mem files
|
||||||
py.test --capture=fd # also point filedescriptors 1 and 2 to temp file
|
py.test --capture=fd # also point filedescriptors 1 and 2 to temp file
|
||||||
|
|
||||||
If you set capturing values in a conftest file like this::
|
|
||||||
|
|
||||||
# conftest.py
|
|
||||||
option_capture = 'fd'
|
|
||||||
|
|
||||||
then all tests in that directory will execute with "fd" style capturing.
|
|
||||||
|
|
||||||
_ `printdebugging`:
|
|
||||||
|
|
||||||
Accessing captured output from a test function
|
Accessing captured output from a test function
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
|
@ -15,7 +15,7 @@ Contact channels
|
||||||
|
|
||||||
- #pylib on irc.freenode.net IRC channel for random questions.
|
- #pylib on irc.freenode.net IRC channel for random questions.
|
||||||
|
|
||||||
- private mail to Holger.Krekel at gmail com if you have sensitive issues to communicate
|
- private mail to Holger.Krekel at gmail com if you want to communicate sensitive issues
|
||||||
|
|
||||||
- `commit mailing list`_
|
- `commit mailing list`_
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ Welcome to ``py.test``!
|
||||||
|
|
||||||
- runs on Posix/Windows, Python 2.4-3.2, PyPy and Jython
|
- runs on Posix/Windows, Python 2.4-3.2, PyPy and Jython
|
||||||
- continously `tested on many Python interpreters <http://hudson.testrun.org/view/pytest/job/pytest/>`_
|
- continously `tested on many Python interpreters <http://hudson.testrun.org/view/pytest/job/pytest/>`_
|
||||||
- used in :ref:`many projects <projects>`, ranging from 10 to 10000 tests
|
- used in :ref:`many projects and organisations <projects>`, ranging from 10 to 10000 tests
|
||||||
- has :ref:`comprehensive documentation <toc>`
|
- has :ref:`comprehensive documentation <toc>`
|
||||||
- comes with :ref:`tested examples <examples>`
|
- comes with :ref:`tested examples <examples>`
|
||||||
- supports :ref:`good integration practises <goodpractises>`
|
- supports :ref:`good integration practises <goodpractises>`
|
||||||
|
@ -18,7 +18,8 @@ Welcome to ``py.test``!
|
||||||
- makes it :ref:`easy to get started <getstarted>`, refined :ref:`usage options <usage>`
|
- makes it :ref:`easy to get started <getstarted>`, refined :ref:`usage options <usage>`
|
||||||
- :ref:`assert with the assert statement`
|
- :ref:`assert with the assert statement`
|
||||||
- helpful :ref:`traceback and failing assertion reporting <tbreportdemo>`
|
- helpful :ref:`traceback and failing assertion reporting <tbreportdemo>`
|
||||||
- allows `print debugging <printdebugging>`_ and `generic output capturing <captures>`_
|
- allows :ref:`print debugging <printdebugging>` and :ref:`generic output
|
||||||
|
capturing <captures>`
|
||||||
- supports :pep:`8` compliant coding style in tests
|
- supports :pep:`8` compliant coding style in tests
|
||||||
|
|
||||||
- **supports functional testing and complex test setups**
|
- **supports functional testing and complex test setups**
|
||||||
|
|
|
@ -3,18 +3,21 @@
|
||||||
Project examples
|
Project examples
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Here are some examples of projects using py.test:
|
Here are some examples of projects using py.test (please send notes via :ref:`contact`):
|
||||||
|
|
||||||
* `PyPy <http://pypy.org>`_, Python with a JIT compiler, running over `16000 tests <http://test.pypy.org>`_
|
* `PyPy <http://pypy.org>`_, Python with a JIT compiler, running over `16000 tests <http://test.pypy.org>`_
|
||||||
* the `MoinMoin <http://moinmo.in>`_ Wiki Engine
|
* the `MoinMoin <http://moinmo.in>`_ Wiki Engine
|
||||||
* `tox <http://codespeak.net/tox>`_, virtualenv/Hudson integration tool
|
* `tox <http://codespeak.net/tox>`_, virtualenv/Hudson integration tool
|
||||||
* `PIDA <http://pida.co.uk>`_ framework for integrated development
|
* `PIDA <http://pida.co.uk>`_ framework for integrated development
|
||||||
|
* `PyPM <http://code.activestate.com/pypm/>`_ ActiveState's package manager
|
||||||
* `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB
|
* `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB
|
||||||
|
* `applib <https://github.com/ActiveState/applib>`_ cross-platform utilities
|
||||||
* `six <http://pypi.python.org/pypi/six/>`_ Python 2 and 3 compatibility utilities
|
* `six <http://pypi.python.org/pypi/six/>`_ Python 2 and 3 compatibility utilities
|
||||||
* `pediapress <http://code.pediapress.com/wiki/wiki>`_ MediaWiki articles
|
* `pediapress <http://code.pediapress.com/wiki/wiki>`_ MediaWiki articles
|
||||||
* `mwlib <http://pypi.python.org/pypi/mwlib>`_ mediawiki parser and utility library
|
* `mwlib <http://pypi.python.org/pypi/mwlib>`_ mediawiki parser and utility library
|
||||||
* `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion
|
* `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion
|
||||||
* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
|
* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
|
||||||
|
* `pylib <http://pylib.org>`_ cross-platform path, IO, dynamic code library
|
||||||
* `Pacha <http://pacha.cafepais.com/>`_ configuration management in five minutes
|
* `Pacha <http://pacha.cafepais.com/>`_ configuration management in five minutes
|
||||||
* `bbfreeze <http://pypi.python.org/pypi/bbfreeze>`_ create standalone executables from Python scripts
|
* `bbfreeze <http://pypi.python.org/pypi/bbfreeze>`_ create standalone executables from Python scripts
|
||||||
* `pdb++ <http://bitbucket.org/antocuni/pdb>`_ a fancier version of PDB
|
* `pdb++ <http://bitbucket.org/antocuni/pdb>`_ a fancier version of PDB
|
||||||
|
@ -34,15 +37,15 @@ Here are some examples of projects using py.test:
|
||||||
* `bu <http://packages.python.org/bu/>`_ a microscopic build system
|
* `bu <http://packages.python.org/bu/>`_ a microscopic build system
|
||||||
* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
|
* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
|
||||||
* `kss plugin timer <http://pypi.python.org/pypi/kss.plugin.timer>`_
|
* `kss plugin timer <http://pypi.python.org/pypi/kss.plugin.timer>`_
|
||||||
* many more ... (please send notes via the :ref:`contact`)
|
|
||||||
|
|
||||||
Some organisations using py.test
|
Some organisations using py.test
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
* `Square Kilometre Array <http://ska.ac.za/>`_
|
* `Square Kilometre Array, Cape Town <http://ska.ac.za/>`_
|
||||||
* `Tandberg <http://www.tandberg.com/>`_
|
* `Tandberg <http://www.tandberg.com/>`_
|
||||||
* `Stups department of Heinrich Heine University <http://www.stups.uni-duesseldorf.de/projects.php>`_
|
* `Shootq <http://web.shootq.com/>`_
|
||||||
* `Open End <http://openend.se>`_
|
* `Stups department of Heinrich Heine University Düsseldorf <http://www.stups.uni-duesseldorf.de/projects.php>`_
|
||||||
* `Laboraratory of Bioinformatics <http://genesilico.pl/>`_
|
* `Open End, Gotenborg <http://www.openend.se>`_
|
||||||
* `merlinux <http://merlinux.eu>`_
|
* `Laboraratory of Bioinformatics, Warsaw <http://genesilico.pl/>`_
|
||||||
|
* `merlinux, Germany <http://merlinux.eu>`_
|
||||||
* many more ... (please be so kind to send a note via :ref:`contact`)
|
* many more ... (please be so kind to send a note via :ref:`contact`)
|
||||||
|
|
|
@ -148,7 +148,7 @@ environment this command will send each tests to all
|
||||||
platforms - and report back failures from all platforms
|
platforms - and report back failures from all platforms
|
||||||
at once. The specifications strings use the `xspec syntax`_.
|
at once. The specifications strings use the `xspec syntax`_.
|
||||||
|
|
||||||
.. _`xspec syntax`: http://codespeak.net/execnet/trunk/basics.html#xspec
|
.. _`xspec syntax`: http://codespeak.net/execnet/basics.html#xspec
|
||||||
|
|
||||||
.. _`socketserver.py`: http://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
|
.. _`socketserver.py`: http://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
|
||||||
|
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -23,7 +23,7 @@ basepython=python2.7
|
||||||
deps=pytest-xdist
|
deps=pytest-xdist
|
||||||
commands=
|
commands=
|
||||||
py.test -n3 -rfsxX \
|
py.test -n3 -rfsxX \
|
||||||
--junitxml={envlogdir}/junit-{envname}.xml []
|
--ignore .tox --junitxml={envlogdir}/junit-{envname}.xml []
|
||||||
|
|
||||||
[testenv:trial]
|
[testenv:trial]
|
||||||
changedir=.
|
changedir=.
|
||||||
|
@ -68,7 +68,7 @@ commands=
|
||||||
[pytest]
|
[pytest]
|
||||||
minversion=2.0
|
minversion=2.0
|
||||||
plugins=pytester
|
plugins=pytester
|
||||||
addopts= -rxf --pyargs --doctest-modules
|
addopts= -rxf --pyargs --doctest-modules --ignore=.tox
|
||||||
rsyncdirs=tox.ini pytest.py _pytest testing
|
rsyncdirs=tox.ini pytest.py _pytest testing
|
||||||
python_files=test_*.py *_test.py
|
python_files=test_*.py *_test.py
|
||||||
python_classes=Test Acceptance
|
python_classes=Test Acceptance
|
||||||
|
|
Loading…
Reference in New Issue