tons and tons of refinements and additions to docs
This commit is contained in:
parent
8d4c9ec343
commit
1df0eaa387
|
@ -7,6 +7,8 @@ Changes between 1.3.4 and 2.0.0dev0
|
|||
some custom plugins early.
|
||||
- try harder to run unittest test suites in a more compatible manner
|
||||
by deferring setup/teardown semantics to the unittest package.
|
||||
also work harder to run twisted/trial and Django tests which
|
||||
should now basically work by default.
|
||||
- introduce a new way to set config options via ini-style files,
|
||||
by default setup.cfg and tox.ini files are searched. The old
|
||||
ways (certain environment variables, dynamic conftest.py reading
|
||||
|
|
|
@ -6,6 +6,7 @@ include LICENSE
|
|||
#include conftest.py
|
||||
graft doc
|
||||
graft testing
|
||||
exclude doc/_build
|
||||
include testing
|
||||
#exclude *.orig
|
||||
#exclude *.orig
|
||||
|
|
|
@ -40,7 +40,8 @@ def showhelp(config):
|
|||
tw.line()
|
||||
tw.line()
|
||||
#tw.sep( "=", "config file settings")
|
||||
tw.line("setup.cfg or tox.ini options to be put into [pytest] section:")
|
||||
tw.line("[pytest] ini-options in the next "
|
||||
"pytest.ini|tox.ini|setup.cfg file:")
|
||||
tw.line()
|
||||
|
||||
for name in config._parser._ininames:
|
||||
|
|
|
@ -775,33 +775,34 @@ def getlocation(function, curdir):
|
|||
# builtin pytest.raises helper
|
||||
|
||||
def raises(ExpectedException, *args, **kwargs):
|
||||
""" assert that a code block/function call raises an exception.
|
||||
|
||||
If using Python 2.5 or above, you may use this function as a
|
||||
context manager::
|
||||
|
||||
>>> with raises(ZeroDivisionError):
|
||||
... 1/0
|
||||
|
||||
Or you can specify a callable by passing a to-be-called lambda::
|
||||
|
||||
>>> raises(ZeroDivisionError, lambda: 1/0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
or you can specify an arbitrary callable with arguments::
|
||||
|
||||
>>> def f(x): return 1/x
|
||||
...
|
||||
>>> raises(ZeroDivisionError, f, 0)
|
||||
<ExceptionInfo ...>
|
||||
>>> raises(ZeroDivisionError, f, x=0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
A third possibility is to use a string which which will
|
||||
be executed::
|
||||
""" assert that a code block/function call raises @ExpectedException
|
||||
and raise a failure exception otherwise.
|
||||
|
||||
>>> raises(ZeroDivisionError, "f(0)")
|
||||
<ExceptionInfo ...>
|
||||
If using Python 2.5 or above, you may use this function as a
|
||||
context manager::
|
||||
|
||||
>>> with raises(ZeroDivisionError):
|
||||
... 1/0
|
||||
|
||||
Or you can specify a callable by passing a to-be-called lambda::
|
||||
|
||||
>>> raises(ZeroDivisionError, lambda: 1/0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
or you can specify an arbitrary callable with arguments::
|
||||
|
||||
>>> def f(x): return 1/x
|
||||
...
|
||||
>>> raises(ZeroDivisionError, f, 0)
|
||||
<ExceptionInfo ...>
|
||||
>>> raises(ZeroDivisionError, f, x=0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
A third possibility is to use a string which which will
|
||||
be executed::
|
||||
|
||||
>>> raises(ZeroDivisionError, "f(0)")
|
||||
<ExceptionInfo ...>
|
||||
"""
|
||||
__tracebackhide__ = True
|
||||
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
<p>
|
||||
<a href="http://pypi.python.org/pypi/pytest">pytest on PyPI</a>
|
||||
</p>
|
||||
<pre>easy_install pytest</pre>
|
||||
<pre>pip install pytest</pre>
|
||||
{% endif %}
|
||||
|
||||
<h3>Questions? Suggestions?</h3>
|
||||
|
||||
<p>Checkout <a href="{{ pathto('contact') }}">support channels</a>
|
||||
<p><a href="{{ pathto('contact') }}">contact channels</a>
|
||||
</p>
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
|
||||
{% block header %}
|
||||
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
|
||||
<h1>tox: virtualenv-based automation of test activities</h1>
|
||||
<h1>pytest: rapid no-boilerplate testing with Python</h1>
|
||||
<div style="text-align: left; font-size: 130%; vertical-align: middle;">
|
||||
<a href="{{ pathto('index') }}">home</a> |
|
||||
<a href="{{ pathto('contents') }}">all docs</a> |
|
||||
<a href="{{ pathto('getting-started') }}">install</a> |
|
||||
<a href="{{ pathto('example/index') }}">examples</a> |
|
||||
<a href="{{ pathto('customize') }}">customize</a> |
|
||||
|
|
|
@ -7,20 +7,3 @@ Release announcements
|
|||
|
||||
release-2.0.0
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
release-1.3.4
|
||||
release-1.3.3
|
||||
release-1.3.2
|
||||
release-1.3.1
|
||||
release-1.3.0
|
||||
release-1.2.1
|
||||
release-1.2.0
|
||||
release-1.1.1
|
||||
release-1.1.0
|
||||
release-1.0.2
|
||||
release-1.0.1
|
||||
release-1.0.0
|
||||
release-0.9.2
|
||||
release-0.9.0
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
py lib 1.0.0: XXX
|
||||
======================================================================
|
||||
|
||||
Welcome to the 1.0.0 py lib release - a library aiming to
|
||||
support agile and test-driven python development on various levels.
|
||||
|
||||
XXX
|
|
@ -1,27 +0,0 @@
|
|||
py lib 0.9.2: bugfix release
|
||||
=============================
|
||||
|
||||
Welcome to the 0.9.2 py lib and py.test release -
|
||||
mainly fixing Windows issues, providing better
|
||||
packaging and integration with setuptools.
|
||||
|
||||
Here is a quick summary of what the py lib provides:
|
||||
|
||||
* py.test: cross-project testing tool with many advanced features
|
||||
* py.execnet: ad-hoc code distribution to SSH, Socket and local sub processes
|
||||
* py.magic.greenlet: micro-threads on standard CPython ("stackless-light")
|
||||
* py.path: path abstractions over local and subversion files
|
||||
* rich documentation of py's exported API
|
||||
* tested against Linux, Win32, OSX, works on python 2.3-2.6
|
||||
|
||||
See here for more information:
|
||||
|
||||
Pypi pages: http://pypi.python.org/pypi/py/
|
||||
|
||||
Download/Install: http://codespeak.net/py/0.9.2/download.html
|
||||
|
||||
Documentation/API: http://codespeak.net/py/0.9.2/index.html
|
||||
|
||||
best and have fun,
|
||||
|
||||
holger krekel
|
|
@ -1,63 +0,0 @@
|
|||
|
||||
pylib 1.0.0 released: testing-with-python innovations continue
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Took a few betas but finally i uploaded a `1.0.0 py lib release`_,
|
||||
featuring the mature and powerful py.test tool and "execnet-style"
|
||||
*elastic* distributed programming. With the new release, there are
|
||||
many new advanced automated testing features - here is a quick summary:
|
||||
|
||||
* funcargs_ - pythonic zero-boilerplate fixtures for Python test functions :
|
||||
|
||||
- totally separates test code, test configuration and test setup
|
||||
- ideal for integration and functional tests
|
||||
- allows for flexible and natural test parametrization schemes
|
||||
|
||||
* new `plugin architecture`_, allowing easy-to-write project-specific and cross-project single-file plugins. The most notable new external plugin is `oejskit`_ which naturally enables **running and reporting of javascript-unittests in real-life browsers**.
|
||||
|
||||
* many new features done in easy-to-improve `default plugins`_, highlights:
|
||||
|
||||
* xfail: mark tests as "expected to fail" and report separately.
|
||||
* pastebin: automatically send tracebacks to pocoo paste service
|
||||
* capture: flexibly capture stdout/stderr of subprocesses, per-test ...
|
||||
* monkeypatch: safely monkeypatch modules/classes from within tests
|
||||
* unittest: run and integrate traditional unittest.py tests
|
||||
* figleaf: generate html coverage reports with the figleaf module
|
||||
* resultlog: generate buildbot-friendly reporting output
|
||||
* ...
|
||||
|
||||
* `distributed testing`_ and `elastic distributed execution`_:
|
||||
|
||||
- new unified "TX" URL scheme for specifying remote processes
|
||||
- new distribution modes "--dist=each" and "--dist=load"
|
||||
- new sync/async ways to handle 1:N communication
|
||||
- improved documentation
|
||||
|
||||
The py lib continues to offer most of the functionality used by
|
||||
the testing tool in `independent namespaces`_.
|
||||
|
||||
Some non-test related code, notably greenlets/co-routines and
|
||||
api-generation now live as their own projects which simplifies the
|
||||
installation procedure because no C-Extensions are required anymore.
|
||||
|
||||
The whole package should work well with Linux, Win32 and OSX, on Python
|
||||
2.3, 2.4, 2.5 and 2.6. (Expect Python3 compatibility soon!)
|
||||
|
||||
For more info, see the py.test and py lib documentation:
|
||||
|
||||
http://pytest.org
|
||||
|
||||
http://pylib.org
|
||||
|
||||
have fun,
|
||||
holger
|
||||
|
||||
.. _`independent namespaces`: http://pylib.org
|
||||
.. _`funcargs`: http://codespeak.net/py/dist/test/funcargs.html
|
||||
.. _`plugin architecture`: http://codespeak.net/py/dist/test/extend.html
|
||||
.. _`default plugins`: http://codespeak.net/py/dist/test/plugin/index.html
|
||||
.. _`distributed testing`: http://codespeak.net/py/dist/test/dist.html
|
||||
.. _`elastic distributed execution`: http://codespeak.net/py/dist/execnet.html
|
||||
.. _`1.0.0 py lib release`: http://pypi.python.org/pypi/py
|
||||
.. _`oejskit`: http://codespeak.net/py/dist/test/plugin/oejskit.html
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
1.0.1: improved reporting, nose/unittest.py support, bug fixes
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
This is a bugfix release of pylib/py.test also coming with:
|
||||
|
||||
* improved documentation, improved navigation
|
||||
* test failure reporting improvements
|
||||
* support for directly running existing nose/unittest.py style tests
|
||||
|
||||
visit here for more info, including quickstart and tutorials:
|
||||
|
||||
http://pytest.org and http://pylib.org
|
||||
|
||||
|
||||
Changelog 1.0.0 to 1.0.1
|
||||
------------------------
|
||||
|
||||
* added a default 'pytest_nose' plugin which handles nose.SkipTest,
|
||||
nose-style function/method/generator setup/teardown and
|
||||
tries to report functions correctly.
|
||||
|
||||
* improved documentation, better navigation: see http://pytest.org
|
||||
|
||||
* added a "--help-config" option to show conftest.py / ENV-var names for
|
||||
all longopt cmdline options, and some special conftest.py variables.
|
||||
renamed 'conf_capture' conftest setting to 'option_capture' accordingly.
|
||||
|
||||
* unicode fixes: capturing and unicode writes to sys.stdout
|
||||
(through e.g a print statement) now work within tests,
|
||||
they are encoded as "utf8" by default, also terminalwriting
|
||||
was adapted and somewhat unified between windows and linux
|
||||
|
||||
* fix issue #27: better reporting on non-collectable items given on commandline
|
||||
(e.g. pyc files)
|
||||
|
||||
* fix issue #33: added --version flag (thanks Benjamin Peterson)
|
||||
|
||||
* fix issue #32: adding support for "incomplete" paths to wcpath.status()
|
||||
|
||||
* "Test" prefixed classes are *not* collected by default anymore if they
|
||||
have an __init__ method
|
||||
|
||||
* monkeypatch setenv() now accepts a "prepend" parameter
|
||||
|
||||
* improved reporting of collection error tracebacks
|
||||
|
||||
* simplified multicall mechanism and plugin architecture,
|
||||
renamed some internal methods and argnames
|
|
@ -1,5 +0,0 @@
|
|||
1.0.2: packaging fixes
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
this release is purely a release for fixing packaging issues.
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
py.test/pylib 1.1.0: Python3, Jython, advanced skipping, cleanups ...
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Features:
|
||||
|
||||
* compatible to Python3 (single py2/py3 source), `easy to install`_
|
||||
* conditional skipping_: skip/xfail based on platform/dependencies
|
||||
* generalized marking_: mark tests one a whole-class or whole-module basis
|
||||
|
||||
Fixes:
|
||||
|
||||
* code reduction and "de-magification" (e.g. 23 KLoc -> 11 KLOC)
|
||||
* distribute testing requires the now separately released execnet_ package
|
||||
* funcarg-setup/caching, "same-name" test modules now cause an exlicit error
|
||||
* de-cluttered reporting options, --report for skipped/xfail details
|
||||
|
||||
Compatibilities
|
||||
|
||||
1.1.0 should allow running test code that already worked well with 1.0.2
|
||||
plus some more due to improved unittest/nose compatibility.
|
||||
|
||||
More information: http://pytest.org
|
||||
|
||||
thanks and have fun,
|
||||
|
||||
holger (http://twitter.com/hpk42)
|
||||
|
||||
.. _execnet: http://codespeak.net/execnet
|
||||
.. _`easy to install`: ../install.html
|
||||
.. _marking: ../test/plugin/mark.html
|
||||
.. _skipping: ../test/plugin/skipping.html
|
||||
|
||||
|
||||
Changelog 1.0.2 -> 1.1.0
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
* remove py.rest tool and internal namespace - it was
|
||||
never really advertised and can still be used with
|
||||
the old release if needed. If there is interest
|
||||
it could be revived into its own tool i guess.
|
||||
|
||||
* fix issue48 and issue59: raise an Error if the module
|
||||
from an imported test file does not seem to come from
|
||||
the filepath - avoids "same-name" confusion that has
|
||||
been reported repeatedly
|
||||
|
||||
* merged Ronny's nose-compatibility hacks: now
|
||||
nose-style setup_module() and setup() functions are
|
||||
supported
|
||||
|
||||
* introduce generalized py.test.mark function marking
|
||||
|
||||
* reshuffle / refine command line grouping
|
||||
|
||||
* deprecate parser.addgroup in favour of getgroup which creates option group
|
||||
|
||||
* add --report command line option that allows to control showing of skipped/xfailed sections
|
||||
|
||||
* generalized skipping: a new way to mark python functions with skipif or xfail
|
||||
at function, class and modules level based on platform or sys-module attributes.
|
||||
|
||||
* extend py.test.mark decorator to allow for positional args
|
||||
|
||||
* introduce and test "py.cleanup -d" to remove empty directories
|
||||
|
||||
* fix issue #59 - robustify unittest test collection
|
||||
|
||||
* make bpython/help interaction work by adding an __all__ attribute
|
||||
to ApiModule, cleanup initpkg
|
||||
|
||||
* use MIT license for pylib, add some contributors
|
||||
|
||||
* remove py.execnet code and substitute all usages with 'execnet' proper
|
||||
|
||||
* fix issue50 - cached_setup now caches more to expectations
|
||||
for test functions with multiple arguments.
|
||||
|
||||
* merge Jarko's fixes, issue #45 and #46
|
||||
|
||||
* add the ability to specify a path for py.lookup to search in
|
||||
|
||||
* fix a funcarg cached_setup bug probably only occuring
|
||||
in distributed testing and "module" scope with teardown.
|
||||
|
||||
* many fixes and changes for making the code base python3 compatible,
|
||||
many thanks to Benjamin Peterson for helping with this.
|
||||
|
||||
* consolidate builtins implementation to be compatible with >=2.3,
|
||||
add helpers to ease keeping 2 and 3k compatible code
|
||||
|
||||
* deprecate py.compat.doctest|subprocess|textwrap|optparse
|
||||
|
||||
* deprecate py.magic.autopath, remove py/magic directory
|
||||
|
||||
* move pytest assertion handling to py/code and a pytest_assertion
|
||||
plugin, add "--no-assert" option, deprecate py.magic namespaces
|
||||
in favour of (less) py.code ones.
|
||||
|
||||
* consolidate and cleanup py/code classes and files
|
||||
|
||||
* cleanup py/misc, move tests to bin-for-dist
|
||||
|
||||
* introduce delattr/delitem/delenv methods to py.test's monkeypatch funcarg
|
||||
|
||||
* consolidate py.log implementation, remove old approach.
|
||||
|
||||
* introduce py.io.TextIO and py.io.BytesIO for distinguishing between
|
||||
text/unicode and byte-streams (uses underlying standard lib io.*
|
||||
if available)
|
||||
|
||||
* make py.unittest_convert helper script available which converts "unittest.py"
|
||||
style files into the simpler assert/direct-test-classes py.test/nosetests
|
||||
style. The script was written by Laura Creighton.
|
||||
|
||||
* simplified internal localpath implementation
|
|
@ -1,48 +0,0 @@
|
|||
py.test/pylib 1.1.1: bugfix release, setuptools plugin registration
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
This is a compatibility fixing release of pylib/py.test to work
|
||||
better with previous 1.0.x test code bases. It also contains fixes
|
||||
and changes to work with `execnet>=1.0.0`_ to provide distributed
|
||||
testing and looponfailing testing modes. py-1.1.1 also introduces
|
||||
a new mechanism for registering plugins via setuptools.
|
||||
|
||||
What is pylib/py.test?
|
||||
-----------------------
|
||||
|
||||
py.test is an advanced automated testing tool working with
|
||||
Python2, Python3 and Jython versions on all major operating
|
||||
systems. It has an extensive plugin architecture and can run many
|
||||
existing common Python test suites without modification. Moreover,
|
||||
it offers some unique features not found in other
|
||||
testing tools. See http://pytest.org for more info.
|
||||
|
||||
The pylib also contains a localpath and svnpath implementation
|
||||
and some developer-oriented command line tools. See
|
||||
http://pylib.org for more info.
|
||||
|
||||
thanks to all who helped and gave feedback,
|
||||
have fun,
|
||||
|
||||
holger (http://twitter.com/hpk42)
|
||||
|
||||
.. _`execnet>=1.0.0`: http://codespeak.net/execnet
|
||||
|
||||
Changes between 1.1.1 and 1.1.0
|
||||
=====================================
|
||||
|
||||
- introduce automatic plugin registration via 'pytest11'
|
||||
entrypoints via setuptools' pkg_resources.iter_entry_points
|
||||
|
||||
- fix py.test dist-testing to work with execnet >= 1.0.0b4
|
||||
|
||||
- re-introduce py.test.cmdline.main() for better backward compatibility
|
||||
|
||||
- svn paths: fix a bug with path.check(versioned=True) for svn paths,
|
||||
allow '%' in svn paths, make svnwc.update() default to interactive mode
|
||||
like in 1.0.x and add svnwc.update(interactive=False) to inhibit interaction.
|
||||
|
||||
- refine distributed tarball to contain test and no pyc files
|
||||
|
||||
- try harder to have deprecation warnings for py.compat.* accesses
|
||||
report a correct location
|
|
@ -1,116 +0,0 @@
|
|||
py.test/pylib 1.2.0: junitxml, standalone test scripts, pluginization
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
py.test is an advanced automated testing tool working with
|
||||
Python2, Python3 and Jython versions on all major operating
|
||||
systems. It has a simple plugin architecture and can run many
|
||||
existing common Python test suites without modification. It offers
|
||||
some unique features not found in other testing tools.
|
||||
See http://pytest.org for more info.
|
||||
|
||||
py.test 1.2.0 brings many bug fixes and interesting new abilities:
|
||||
|
||||
* --junitxml=path will create an XML file for use with CI processing
|
||||
* --genscript=path creates a standalone py.test-equivalent test-script
|
||||
* --ignore=path prevents collection of anything below that path
|
||||
* --confcutdir=path only lookup conftest.py test configs below that path
|
||||
* a 'pytest_report_header' hook to add info to the terminal report header
|
||||
* a 'pytestconfig' function argument gives direct access to option values
|
||||
* 'pytest_generate_tests' can now be put into a class as well
|
||||
* on CPython py.test additionally installs as "py.test-VERSION", on
|
||||
Jython as py.test-jython and on PyPy as py.test-pypy-XYZ
|
||||
|
||||
Apart from many bug fixes 1.2.0 also has better pluginization:
|
||||
Distributed testing and looponfailing testing now live in the
|
||||
separately installable 'pytest-xdist' plugin. The same is true for
|
||||
'pytest-figleaf' for doing coverage reporting. Those two plugins
|
||||
can serve well now as blue prints for doing your own.
|
||||
|
||||
thanks to all who helped and gave feedback,
|
||||
have fun,
|
||||
|
||||
holger krekel, January 2010
|
||||
|
||||
Changes between 1.2.0 and 1.1.1
|
||||
=====================================
|
||||
|
||||
- moved dist/looponfailing from py.test core into a new
|
||||
separately released pytest-xdist plugin.
|
||||
|
||||
- new junitxml plugin: --junitxml=path will generate a junit style xml file
|
||||
which is processable e.g. by the Hudson CI system.
|
||||
|
||||
- new option: --genscript=path will generate a standalone py.test script
|
||||
which will not need any libraries installed. thanks to Ralf Schmitt.
|
||||
|
||||
- new option: --ignore will prevent specified path from collection.
|
||||
Can be specified multiple times.
|
||||
|
||||
- new option: --confcutdir=dir will make py.test only consider conftest
|
||||
files that are relative to the specified dir.
|
||||
|
||||
- new funcarg: "pytestconfig" is the pytest config object for access
|
||||
to command line args and can now be easily used in a test.
|
||||
|
||||
- install 'py.test' and `py.which` with a ``-$VERSION`` suffix to
|
||||
disambiguate between Python3, python2.X, Jython and PyPy installed versions.
|
||||
|
||||
- new "pytestconfig" funcarg allows access to test config object
|
||||
|
||||
- new "pytest_report_header" hook can return additional lines
|
||||
to be displayed at the header of a test run.
|
||||
|
||||
- (experimental) allow "py.test path::name1::name2::..." for pointing
|
||||
to a test within a test collection directly. This might eventually
|
||||
evolve as a full substitute to "-k" specifications.
|
||||
|
||||
- streamlined plugin loading: order is now as documented in
|
||||
customize.html: setuptools, ENV, commandline, conftest.
|
||||
also setuptools entry point names are turned to canonical namees ("pytest_*")
|
||||
|
||||
- automatically skip tests that need 'capfd' but have no os.dup
|
||||
|
||||
- allow pytest_generate_tests to be defined in classes as well
|
||||
|
||||
- deprecate usage of 'disabled' attribute in favour of pytestmark
|
||||
- deprecate definition of Directory, Module, Class and Function nodes
|
||||
in conftest.py files. Use pytest collect hooks instead.
|
||||
|
||||
- collection/item node specific runtest/collect hooks are only called exactly
|
||||
on matching conftest.py files, i.e. ones which are exactly below
|
||||
the filesystem path of an item
|
||||
|
||||
- change: the first pytest_collect_directory hook to return something
|
||||
will now prevent further hooks to be called.
|
||||
|
||||
- change: figleaf plugin now requires --figleaf to run. Also
|
||||
change its long command line options to be a bit shorter (see py.test -h).
|
||||
|
||||
- change: pytest doctest plugin is now enabled by default and has a
|
||||
new option --doctest-glob to set a pattern for file matches.
|
||||
|
||||
- change: remove internal py._* helper vars, only keep py._pydir
|
||||
|
||||
- robustify capturing to survive if custom pytest_runtest_setup
|
||||
code failed and prevented the capturing setup code from running.
|
||||
|
||||
- make py.test.* helpers provided by default plugins visible early -
|
||||
works transparently both for pydoc and for interactive sessions
|
||||
which will regularly see e.g. py.test.mark and py.test.importorskip.
|
||||
|
||||
- simplify internal plugin manager machinery
|
||||
- simplify internal collection tree by introducing a RootCollector node
|
||||
|
||||
- fix assert reinterpreation that sees a call containing "keyword=..."
|
||||
|
||||
- fix issue66: invoke pytest_sessionstart and pytest_sessionfinish
|
||||
hooks on slaves during dist-testing, report module/session teardown
|
||||
hooks correctly.
|
||||
|
||||
- fix issue65: properly handle dist-testing if no
|
||||
execnet/py lib installed remotely.
|
||||
|
||||
- skip some install-tests if no execnet is available
|
||||
|
||||
- fix docs, fix internal bin/ script generation
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
py.test/pylib 1.2.1: little fixes and improvements
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
py.test is an advanced automated testing tool working with
|
||||
Python2, Python3 and Jython versions on all major operating
|
||||
systems. It has a simple plugin architecture and can run many
|
||||
existing common Python test suites without modification. It offers
|
||||
some unique features not found in other testing tools.
|
||||
See http://pytest.org for more info.
|
||||
|
||||
py.test 1.2.1 brings bug fixes and some new options and abilities triggered
|
||||
by user feedback:
|
||||
|
||||
* --funcargs [testpath] will show available builtin- and project funcargs.
|
||||
* display a short and concise traceback if funcarg lookup fails.
|
||||
* early-load "conftest.py" files in non-dot first-level sub directories.
|
||||
* --tb=line will print a single line for each failing test (issue67)
|
||||
* py.cleanup has a number of new options, cleanups up setup.py related files
|
||||
* fix issue78: always call python-level teardown functions even if the
|
||||
according setup failed.
|
||||
|
||||
For more detailed information see the changelog below.
|
||||
|
||||
cheers and have fun,
|
||||
|
||||
holger
|
||||
|
||||
|
||||
Changes between 1.2.1 and 1.2.0
|
||||
=====================================
|
||||
|
||||
- refined usage and options for "py.cleanup"::
|
||||
|
||||
py.cleanup # remove "*.pyc" and "*$py.class" (jython) files
|
||||
py.cleanup -e .swp -e .cache # also remove files with these extensions
|
||||
py.cleanup -s # remove "build" and "dist" directory next to setup.py files
|
||||
py.cleanup -d # also remove empty directories
|
||||
py.cleanup -a # synonym for "-s -d -e 'pip-log.txt'"
|
||||
py.cleanup -n # dry run, only show what would be removed
|
||||
|
||||
- add a new option "py.test --funcargs" which shows available funcargs
|
||||
and their help strings (docstrings on their respective factory function)
|
||||
for a given test path
|
||||
|
||||
- display a short and concise traceback if a funcarg lookup fails
|
||||
|
||||
- early-load "conftest.py" files in non-dot first-level sub directories.
|
||||
allows to conveniently keep and access test-related options in a ``test``
|
||||
subdir and still add command line options.
|
||||
|
||||
- fix issue67: new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value
|
||||
|
||||
- fix issue78: always call python-level teardown functions even if the
|
||||
according setup failed. This includes refinements for calling setup_module/class functions
|
||||
which will now only be called once instead of the previous behaviour where they'd be called
|
||||
multiple times if they raise an exception (including a Skipped exception). Any exception
|
||||
will be re-corded and associated with all tests in the according module/class scope.
|
||||
|
||||
- fix issue63: assume <40 columns to be a bogus terminal width, default to 80
|
||||
|
||||
- fix pdb debugging to be in the correct frame on raises-related errors
|
||||
|
||||
- update apipkg.py to fix an issue where recursive imports might
|
||||
unnecessarily break importing
|
||||
|
||||
- fix plugin links
|
|
@ -1,580 +0,0 @@
|
|||
py.test/pylib 1.3.0: new options, per-plugin hooks, fixes ...
|
||||
===========================================================================
|
||||
|
||||
The 1.3.0 release introduces new options, bug fixes and improved compatibility
|
||||
with Python3 and Jython-2.5.1 on Windows. If you already use py-1.2 chances
|
||||
are you can use py-1.3.0. See the below CHANGELOG for more details and
|
||||
http://pylib.org/install.html for installation instructions.
|
||||
|
||||
py.test is an advanced automated testing tool working with Python2,
|
||||
Python3, Jython and PyPy versions on all major operating systems. It
|
||||
offers a no-boilerplate testing approach and has inspired other testing
|
||||
tools and enhancements in the standard Python library for more than five
|
||||
years. It has a simple and extensive plugin architecture, configurable
|
||||
reporting and provides unique ways to make it fit to your testing
|
||||
process and needs.
|
||||
|
||||
See http://pytest.org for more info.
|
||||
|
||||
cheers and have fun,
|
||||
|
||||
holger krekel
|
||||
|
||||
Changes between 1.2.1 and 1.3.0
|
||||
==================================================
|
||||
|
||||
- deprecate --report option in favour of a new shorter and easier to
|
||||
remember -r option: it takes a string argument consisting of any
|
||||
combination of 'xfsX' characters. They relate to the single chars
|
||||
you see during the dotted progress printing and will print an extra line
|
||||
per test at the end of the test run. This extra line indicates the exact
|
||||
position or test ID that you directly paste to the py.test cmdline in order
|
||||
to re-run a particular test.
|
||||
|
||||
- allow external plugins to register new hooks via the new
|
||||
pytest_addhooks(pluginmanager) hook. The new release of
|
||||
the pytest-xdist plugin for distributed and looponfailing
|
||||
testing requires this feature.
|
||||
|
||||
- add a new pytest_ignore_collect(path, config) hook to allow projects and
|
||||
plugins to define exclusion behaviour for their directory structure -
|
||||
for example you may define in a conftest.py this method::
|
||||
|
||||
def pytest_ignore_collect(path):
|
||||
return path.check(link=1)
|
||||
|
||||
to prevent even collection of any tests in symlinked dirs.
|
||||
|
||||
- new pytest_pycollect_makemodule(path, parent) hook for
|
||||
allowing customization of the Module collection object for a
|
||||
matching test module.
|
||||
|
||||
- extend and refine xfail mechanism::
|
||||
|
||||
@py.test.mark.xfail(run=False) do not run the decorated test
|
||||
@py.test.mark.xfail(reason="...") prints the reason string in xfail summaries
|
||||
|
||||
specifiying ``--runxfail`` on command line ignores xfail markers to show
|
||||
you the underlying traceback.
|
||||
|
||||
- expose (previously internal) commonly useful methods:
|
||||
py.io.get_terminal_with() -> return terminal width
|
||||
py.io.ansi_print(...) -> print colored/bold text on linux/win32
|
||||
py.io.saferepr(obj) -> return limited representation string
|
||||
|
||||
- expose test outcome related exceptions as py.test.skip.Exception,
|
||||
py.test.raises.Exception etc., useful mostly for plugins
|
||||
doing special outcome interpretation/tweaking
|
||||
|
||||
- (issue85) fix junitxml plugin to handle tests with non-ascii output
|
||||
|
||||
- fix/refine python3 compatibility (thanks Benjamin Peterson)
|
||||
|
||||
- fixes for making the jython/win32 combination work, note however:
|
||||
jython2.5.1/win32 does not provide a command line launcher, see
|
||||
http://bugs.jython.org/issue1491 . See pylib install documentation
|
||||
for how to work around.
|
||||
|
||||
- fixes for handling of unicode exception values and unprintable objects
|
||||
|
||||
- (issue87) fix unboundlocal error in assertionold code
|
||||
|
||||
- (issue86) improve documentation for looponfailing
|
||||
|
||||
- refine IO capturing: stdin-redirect pseudo-file now has a NOP close() method
|
||||
|
||||
- ship distribute_setup.py version 0.6.10
|
||||
|
||||
- added links to the new capturelog and coverage plugins
|
||||
|
||||
|
||||
Changes between 1.2.1 and 1.2.0
|
||||
=====================================
|
||||
|
||||
- refined usage and options for "py.cleanup"::
|
||||
|
||||
py.cleanup # remove "*.pyc" and "*$py.class" (jython) files
|
||||
py.cleanup -e .swp -e .cache # also remove files with these extensions
|
||||
py.cleanup -s # remove "build" and "dist" directory next to setup.py files
|
||||
py.cleanup -d # also remove empty directories
|
||||
py.cleanup -a # synonym for "-s -d -e 'pip-log.txt'"
|
||||
py.cleanup -n # dry run, only show what would be removed
|
||||
|
||||
- add a new option "py.test --funcargs" which shows available funcargs
|
||||
and their help strings (docstrings on their respective factory function)
|
||||
for a given test path
|
||||
|
||||
- display a short and concise traceback if a funcarg lookup fails
|
||||
|
||||
- early-load "conftest.py" files in non-dot first-level sub directories.
|
||||
allows to conveniently keep and access test-related options in a ``test``
|
||||
subdir and still add command line options.
|
||||
|
||||
- fix issue67: new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value
|
||||
|
||||
- fix issue78: always call python-level teardown functions even if the
|
||||
according setup failed. This includes refinements for calling setup_module/class functions
|
||||
which will now only be called once instead of the previous behaviour where they'd be called
|
||||
multiple times if they raise an exception (including a Skipped exception). Any exception
|
||||
will be re-corded and associated with all tests in the according module/class scope.
|
||||
|
||||
- fix issue63: assume <40 columns to be a bogus terminal width, default to 80
|
||||
|
||||
- fix pdb debugging to be in the correct frame on raises-related errors
|
||||
|
||||
- update apipkg.py to fix an issue where recursive imports might
|
||||
unnecessarily break importing
|
||||
|
||||
- fix plugin links
|
||||
|
||||
Changes between 1.2 and 1.1.1
|
||||
=====================================
|
||||
|
||||
- moved dist/looponfailing from py.test core into a new
|
||||
separately released pytest-xdist plugin.
|
||||
|
||||
- new junitxml plugin: --junitxml=path will generate a junit style xml file
|
||||
which is processable e.g. by the Hudson CI system.
|
||||
|
||||
- new option: --genscript=path will generate a standalone py.test script
|
||||
which will not need any libraries installed. thanks to Ralf Schmitt.
|
||||
|
||||
- new option: --ignore will prevent specified path from collection.
|
||||
Can be specified multiple times.
|
||||
|
||||
- new option: --confcutdir=dir will make py.test only consider conftest
|
||||
files that are relative to the specified dir.
|
||||
|
||||
- new funcarg: "pytestconfig" is the pytest config object for access
|
||||
to command line args and can now be easily used in a test.
|
||||
|
||||
- install 'py.test' and `py.which` with a ``-$VERSION`` suffix to
|
||||
disambiguate between Python3, python2.X, Jython and PyPy installed versions.
|
||||
|
||||
- new "pytestconfig" funcarg allows access to test config object
|
||||
|
||||
- new "pytest_report_header" hook can return additional lines
|
||||
to be displayed at the header of a test run.
|
||||
|
||||
- (experimental) allow "py.test path::name1::name2::..." for pointing
|
||||
to a test within a test collection directly. This might eventually
|
||||
evolve as a full substitute to "-k" specifications.
|
||||
|
||||
- streamlined plugin loading: order is now as documented in
|
||||
customize.html: setuptools, ENV, commandline, conftest.
|
||||
also setuptools entry point names are turned to canonical namees ("pytest_*")
|
||||
|
||||
- automatically skip tests that need 'capfd' but have no os.dup
|
||||
|
||||
- allow pytest_generate_tests to be defined in classes as well
|
||||
|
||||
- deprecate usage of 'disabled' attribute in favour of pytestmark
|
||||
- deprecate definition of Directory, Module, Class and Function nodes
|
||||
in conftest.py files. Use pytest collect hooks instead.
|
||||
|
||||
- collection/item node specific runtest/collect hooks are only called exactly
|
||||
on matching conftest.py files, i.e. ones which are exactly below
|
||||
the filesystem path of an item
|
||||
|
||||
- change: the first pytest_collect_directory hook to return something
|
||||
will now prevent further hooks to be called.
|
||||
|
||||
- change: figleaf plugin now requires --figleaf to run. Also
|
||||
change its long command line options to be a bit shorter (see py.test -h).
|
||||
|
||||
- change: pytest doctest plugin is now enabled by default and has a
|
||||
new option --doctest-glob to set a pattern for file matches.
|
||||
|
||||
- change: remove internal py._* helper vars, only keep py._pydir
|
||||
|
||||
- robustify capturing to survive if custom pytest_runtest_setup
|
||||
code failed and prevented the capturing setup code from running.
|
||||
|
||||
- make py.test.* helpers provided by default plugins visible early -
|
||||
works transparently both for pydoc and for interactive sessions
|
||||
which will regularly see e.g. py.test.mark and py.test.importorskip.
|
||||
|
||||
- simplify internal plugin manager machinery
|
||||
- simplify internal collection tree by introducing a RootCollector node
|
||||
|
||||
- fix assert reinterpreation that sees a call containing "keyword=..."
|
||||
|
||||
- fix issue66: invoke pytest_sessionstart and pytest_sessionfinish
|
||||
hooks on slaves during dist-testing, report module/session teardown
|
||||
hooks correctly.
|
||||
|
||||
- fix issue65: properly handle dist-testing if no
|
||||
execnet/py lib installed remotely.
|
||||
|
||||
- skip some install-tests if no execnet is available
|
||||
|
||||
- fix docs, fix internal bin/ script generation
|
||||
|
||||
|
||||
Changes between 1.1.1 and 1.1.0
|
||||
=====================================
|
||||
|
||||
- introduce automatic plugin registration via 'pytest11'
|
||||
entrypoints via setuptools' pkg_resources.iter_entry_points
|
||||
|
||||
- fix py.test dist-testing to work with execnet >= 1.0.0b4
|
||||
|
||||
- re-introduce py.test.cmdline.main() for better backward compatibility
|
||||
|
||||
- svn paths: fix a bug with path.check(versioned=True) for svn paths,
|
||||
allow '%' in svn paths, make svnwc.update() default to interactive mode
|
||||
like in 1.0.x and add svnwc.update(interactive=False) to inhibit interaction.
|
||||
|
||||
- refine distributed tarball to contain test and no pyc files
|
||||
|
||||
- try harder to have deprecation warnings for py.compat.* accesses
|
||||
report a correct location
|
||||
|
||||
Changes between 1.1.0 and 1.0.2
|
||||
=====================================
|
||||
|
||||
* adjust and improve docs
|
||||
|
||||
* remove py.rest tool and internal namespace - it was
|
||||
never really advertised and can still be used with
|
||||
the old release if needed. If there is interest
|
||||
it could be revived into its own tool i guess.
|
||||
|
||||
* fix issue48 and issue59: raise an Error if the module
|
||||
from an imported test file does not seem to come from
|
||||
the filepath - avoids "same-name" confusion that has
|
||||
been reported repeatedly
|
||||
|
||||
* merged Ronny's nose-compatibility hacks: now
|
||||
nose-style setup_module() and setup() functions are
|
||||
supported
|
||||
|
||||
* introduce generalized py.test.mark function marking
|
||||
|
||||
* reshuffle / refine command line grouping
|
||||
|
||||
* deprecate parser.addgroup in favour of getgroup which creates option group
|
||||
|
||||
* add --report command line option that allows to control showing of skipped/xfailed sections
|
||||
|
||||
* generalized skipping: a new way to mark python functions with skipif or xfail
|
||||
at function, class and modules level based on platform or sys-module attributes.
|
||||
|
||||
* extend py.test.mark decorator to allow for positional args
|
||||
|
||||
* introduce and test "py.cleanup -d" to remove empty directories
|
||||
|
||||
* fix issue #59 - robustify unittest test collection
|
||||
|
||||
* make bpython/help interaction work by adding an __all__ attribute
|
||||
to ApiModule, cleanup initpkg
|
||||
|
||||
* use MIT license for pylib, add some contributors
|
||||
|
||||
* remove py.execnet code and substitute all usages with 'execnet' proper
|
||||
|
||||
* fix issue50 - cached_setup now caches more to expectations
|
||||
for test functions with multiple arguments.
|
||||
|
||||
* merge Jarko's fixes, issue #45 and #46
|
||||
|
||||
* add the ability to specify a path for py.lookup to search in
|
||||
|
||||
* fix a funcarg cached_setup bug probably only occuring
|
||||
in distributed testing and "module" scope with teardown.
|
||||
|
||||
* many fixes and changes for making the code base python3 compatible,
|
||||
many thanks to Benjamin Peterson for helping with this.
|
||||
|
||||
* consolidate builtins implementation to be compatible with >=2.3,
|
||||
add helpers to ease keeping 2 and 3k compatible code
|
||||
|
||||
* deprecate py.compat.doctest|subprocess|textwrap|optparse
|
||||
|
||||
* deprecate py.magic.autopath, remove py/magic directory
|
||||
|
||||
* move pytest assertion handling to py/code and a pytest_assertion
|
||||
plugin, add "--no-assert" option, deprecate py.magic namespaces
|
||||
in favour of (less) py.code ones.
|
||||
|
||||
* consolidate and cleanup py/code classes and files
|
||||
|
||||
* cleanup py/misc, move tests to bin-for-dist
|
||||
|
||||
* introduce delattr/delitem/delenv methods to py.test's monkeypatch funcarg
|
||||
|
||||
* consolidate py.log implementation, remove old approach.
|
||||
|
||||
* introduce py.io.TextIO and py.io.BytesIO for distinguishing between
|
||||
text/unicode and byte-streams (uses underlying standard lib io.*
|
||||
if available)
|
||||
|
||||
* make py.unittest_convert helper script available which converts "unittest.py"
|
||||
style files into the simpler assert/direct-test-classes py.test/nosetests
|
||||
style. The script was written by Laura Creighton.
|
||||
|
||||
* simplified internal localpath implementation
|
||||
|
||||
Changes between 1.0.1 and 1.0.2
|
||||
=====================================
|
||||
|
||||
* fixing packaging issues, triggered by fedora redhat packaging,
|
||||
also added doc, examples and contrib dirs to the tarball.
|
||||
|
||||
* added a documentation link to the new django plugin.
|
||||
|
||||
Changes between 1.0.0 and 1.0.1
|
||||
=====================================
|
||||
|
||||
* added a 'pytest_nose' plugin which handles nose.SkipTest,
|
||||
nose-style function/method/generator setup/teardown and
|
||||
tries to report functions correctly.
|
||||
|
||||
* capturing of unicode writes or encoded strings to sys.stdout/err
|
||||
work better, also terminalwriting was adapted and somewhat
|
||||
unified between windows and linux.
|
||||
|
||||
* improved documentation layout and content a lot
|
||||
|
||||
* added a "--help-config" option to show conftest.py / ENV-var names for
|
||||
all longopt cmdline options, and some special conftest.py variables.
|
||||
renamed 'conf_capture' conftest setting to 'option_capture' accordingly.
|
||||
|
||||
* fix issue #27: better reporting on non-collectable items given on commandline
|
||||
(e.g. pyc files)
|
||||
|
||||
* fix issue #33: added --version flag (thanks Benjamin Peterson)
|
||||
|
||||
* fix issue #32: adding support for "incomplete" paths to wcpath.status()
|
||||
|
||||
* "Test" prefixed classes are *not* collected by default anymore if they
|
||||
have an __init__ method
|
||||
|
||||
* monkeypatch setenv() now accepts a "prepend" parameter
|
||||
|
||||
* improved reporting of collection error tracebacks
|
||||
|
||||
* simplified multicall mechanism and plugin architecture,
|
||||
renamed some internal methods and argnames
|
||||
|
||||
Changes between 1.0.0b9 and 1.0.0
|
||||
=====================================
|
||||
|
||||
* more terse reporting try to show filesystem path relatively to current dir
|
||||
* improve xfail output a bit
|
||||
|
||||
Changes between 1.0.0b8 and 1.0.0b9
|
||||
=====================================
|
||||
|
||||
* cleanly handle and report final teardown of test setup
|
||||
|
||||
* fix svn-1.6 compat issue with py.path.svnwc().versioned()
|
||||
(thanks Wouter Vanden Hove)
|
||||
|
||||
* setup/teardown or collection problems now show as ERRORs
|
||||
or with big "E"'s in the progress lines. they are reported
|
||||
and counted separately.
|
||||
|
||||
* dist-testing: properly handle test items that get locally
|
||||
collected but cannot be collected on the remote side - often
|
||||
due to platform/dependency reasons
|
||||
|
||||
* simplified py.test.mark API - see keyword plugin documentation
|
||||
|
||||
* integrate better with logging: capturing now by default captures
|
||||
test functions and their immediate setup/teardown in a single stream
|
||||
|
||||
* capsys and capfd funcargs now have a readouterr() and a close() method
|
||||
(underlyingly py.io.StdCapture/FD objects are used which grew a
|
||||
readouterr() method as well to return snapshots of captured out/err)
|
||||
|
||||
* make assert-reinterpretation work better with comparisons not
|
||||
returning bools (reported with numpy from thanks maciej fijalkowski)
|
||||
|
||||
* reworked per-test output capturing into the pytest_iocapture.py plugin
|
||||
and thus removed capturing code from config object
|
||||
|
||||
* item.repr_failure(excinfo) instead of item.repr_failure(excinfo, outerr)
|
||||
|
||||
|
||||
Changes between 1.0.0b7 and 1.0.0b8
|
||||
=====================================
|
||||
|
||||
* pytest_unittest-plugin is now enabled by default
|
||||
|
||||
* introduced pytest_keyboardinterrupt hook and
|
||||
refined pytest_sessionfinish hooked, added tests.
|
||||
|
||||
* workaround a buggy logging module interaction ("closing already closed
|
||||
files"). Thanks to Sridhar Ratnakumar for triggering.
|
||||
|
||||
* if plugins use "py.test.importorskip" for importing
|
||||
a dependency only a warning will be issued instead
|
||||
of exiting the testing process.
|
||||
|
||||
* many improvements to docs:
|
||||
- refined funcargs doc , use the term "factory" instead of "provider"
|
||||
- added a new talk/tutorial doc page
|
||||
- better download page
|
||||
- better plugin docstrings
|
||||
- added new plugins page and automatic doc generation script
|
||||
|
||||
* fixed teardown problem related to partially failing funcarg setups
|
||||
(thanks MrTopf for reporting), "pytest_runtest_teardown" is now
|
||||
always invoked even if the "pytest_runtest_setup" failed.
|
||||
|
||||
* tweaked doctest output for docstrings in py modules,
|
||||
thanks Radomir.
|
||||
|
||||
Changes between 1.0.0b3 and 1.0.0b7
|
||||
=============================================
|
||||
|
||||
* renamed py.test.xfail back to py.test.mark.xfail to avoid
|
||||
two ways to decorate for xfail
|
||||
|
||||
* re-added py.test.mark decorator for setting keywords on functions
|
||||
(it was actually documented so removing it was not nice)
|
||||
|
||||
* remove scope-argument from request.addfinalizer() because
|
||||
request.cached_setup has the scope arg. TOOWTDI.
|
||||
|
||||
* perform setup finalization before reporting failures
|
||||
|
||||
* apply modified patches from Andreas Kloeckner to allow
|
||||
test functions to have no func_code (#22) and to make
|
||||
"-k" and function keywords work (#20)
|
||||
|
||||
* apply patch from Daniel Peolzleithner (issue #23)
|
||||
|
||||
* resolve issue #18, multiprocessing.Manager() and
|
||||
redirection clash
|
||||
|
||||
* make __name__ == "__channelexec__" for remote_exec code
|
||||
|
||||
Changes between 1.0.0b1 and 1.0.0b3
|
||||
=============================================
|
||||
|
||||
* plugin classes are removed: one now defines
|
||||
hooks directly in conftest.py or global pytest_*.py
|
||||
files.
|
||||
|
||||
* added new pytest_namespace(config) hook that allows
|
||||
to inject helpers directly to the py.test.* namespace.
|
||||
|
||||
* documented and refined many hooks
|
||||
|
||||
* added new style of generative tests via
|
||||
pytest_generate_tests hook that integrates
|
||||
well with function arguments.
|
||||
|
||||
|
||||
Changes between 0.9.2 and 1.0.0b1
|
||||
=============================================
|
||||
|
||||
* introduced new "funcarg" setup method,
|
||||
see doc/test/funcarg.txt
|
||||
|
||||
* introduced plugin architecuture and many
|
||||
new py.test plugins, see
|
||||
doc/test/plugins.txt
|
||||
|
||||
* teardown_method is now guaranteed to get
|
||||
called after a test method has run.
|
||||
|
||||
* new method: py.test.importorskip(mod,minversion)
|
||||
will either import or call py.test.skip()
|
||||
|
||||
* completely revised internal py.test architecture
|
||||
|
||||
* new py.process.ForkedFunc object allowing to
|
||||
fork execution of a function to a sub process
|
||||
and getting a result back.
|
||||
|
||||
XXX lots of things missing here XXX
|
||||
|
||||
Changes between 0.9.1 and 0.9.2
|
||||
===============================
|
||||
|
||||
* refined installation and metadata, created new setup.py,
|
||||
now based on setuptools/ez_setup (thanks to Ralf Schmitt
|
||||
for his support).
|
||||
|
||||
* improved the way of making py.* scripts available in
|
||||
windows environments, they are now added to the
|
||||
Scripts directory as ".cmd" files.
|
||||
|
||||
* py.path.svnwc.status() now is more complete and
|
||||
uses xml output from the 'svn' command if available
|
||||
(Guido Wesdorp)
|
||||
|
||||
* fix for py.path.svn* to work with svn 1.5
|
||||
(Chris Lamb)
|
||||
|
||||
* fix path.relto(otherpath) method on windows to
|
||||
use normcase for checking if a path is relative.
|
||||
|
||||
* py.test's traceback is better parseable from editors
|
||||
(follows the filenames:LINENO: MSG convention)
|
||||
(thanks to Osmo Salomaa)
|
||||
|
||||
* fix to javascript-generation, "py.test --runbrowser"
|
||||
should work more reliably now
|
||||
|
||||
* removed previously accidentally added
|
||||
py.test.broken and py.test.notimplemented helpers.
|
||||
|
||||
* there now is a py.__version__ attribute
|
||||
|
||||
Changes between 0.9.0 and 0.9.1
|
||||
===============================
|
||||
|
||||
This is a fairly complete list of changes between 0.9 and 0.9.1, which can
|
||||
serve as a reference for developers.
|
||||
|
||||
* allowing + signs in py.path.svn urls [39106]
|
||||
* fixed support for Failed exceptions without excinfo in py.test [39340]
|
||||
* added support for killing processes for Windows (as well as platforms that
|
||||
support os.kill) in py.misc.killproc [39655]
|
||||
* added setup/teardown for generative tests to py.test [40702]
|
||||
* added detection of FAILED TO LOAD MODULE to py.test [40703, 40738, 40739]
|
||||
* fixed problem with calling .remove() on wcpaths of non-versioned files in
|
||||
py.path [44248]
|
||||
* fixed some import and inheritance issues in py.test [41480, 44648, 44655]
|
||||
* fail to run greenlet tests when pypy is available, but without stackless
|
||||
[45294]
|
||||
* small fixes in rsession tests [45295]
|
||||
* fixed issue with 2.5 type representations in py.test [45483, 45484]
|
||||
* made that internal reporting issues displaying is done atomically in py.test
|
||||
[45518]
|
||||
* made that non-existing files are igored by the py.lookup script [45519]
|
||||
* improved exception name creation in py.test [45535]
|
||||
* made that less threads are used in execnet [merge in 45539]
|
||||
* removed lock required for atomical reporting issue displaying in py.test
|
||||
[45545]
|
||||
* removed globals from execnet [45541, 45547]
|
||||
* refactored cleanup mechanics, made that setDaemon is set to 1 to make atexit
|
||||
get called in 2.5 (py.execnet) [45548]
|
||||
* fixed bug in joining threads in py.execnet's servemain [45549]
|
||||
* refactored py.test.rsession tests to not rely on exact output format anymore
|
||||
[45646]
|
||||
* using repr() on test outcome [45647]
|
||||
* added 'Reason' classes for py.test.skip() [45648, 45649]
|
||||
* killed some unnecessary sanity check in py.test.collect [45655]
|
||||
* avoid using os.tmpfile() in py.io.fdcapture because on Windows it's only
|
||||
usable by Administrators [45901]
|
||||
* added support for locking and non-recursive commits to py.path.svnwc [45994]
|
||||
* locking files in py.execnet to prevent CPython from segfaulting [46010]
|
||||
* added export() method to py.path.svnurl
|
||||
* fixed -d -x in py.test [47277]
|
||||
* fixed argument concatenation problem in py.path.svnwc [49423]
|
||||
* restore py.test behaviour that it exits with code 1 when there are failures
|
||||
[49974]
|
||||
* don't fail on html files that don't have an accompanying .txt file [50606]
|
||||
* fixed 'utestconvert.py < input' [50645]
|
||||
* small fix for code indentation in py.code.source [50755]
|
||||
* fix _docgen.py documentation building [51285]
|
||||
* improved checks for source representation of code blocks in py.test [51292]
|
||||
* added support for passing authentication to py.path.svn* objects [52000,
|
||||
52001]
|
||||
* removed sorted() call for py.apigen tests in favour of [].sort() to support
|
||||
Python 2.3 [52481]
|
|
@ -1,104 +0,0 @@
|
|||
py.test/pylib 1.3.1: new py.test.xfail, --maxfail, better reporting
|
||||
===========================================================================
|
||||
|
||||
The pylib/py.test 1.3.1 release brings:
|
||||
|
||||
- the new imperative ``py.test.xfail()`` helper in order to have a test or
|
||||
setup function result in an "expected failure"
|
||||
- a new option ``--maxfail=NUM`` to stop the test run after some failures
|
||||
- markers/decorators are now applicable to test classes (>=Python2.6)
|
||||
- improved reporting, shorter tracebacks in several cases
|
||||
- some simplified internals, more compatibility with Jython and PyPy
|
||||
- bug fixes and various refinements
|
||||
|
||||
See the below CHANGELOG entry below for more details and
|
||||
http://pylib.org/install.html for installation instructions.
|
||||
|
||||
If you used older versions of py.test you should be able to upgrade
|
||||
to 1.3.1 without changes to your test source code.
|
||||
|
||||
py.test is an automated testing tool working with Python2,
|
||||
Python3, Jython and PyPy versions on all major operating systems. It
|
||||
offers a no-boilerplate testing approach and has inspired other testing
|
||||
tools and enhancements in the standard Python library for more than five
|
||||
years. It has a simple and extensive plugin architecture, configurable
|
||||
reporting and provides unique ways to make it fit to your testing
|
||||
process and needs.
|
||||
|
||||
See http://pytest.org for more info.
|
||||
|
||||
cheers and have fun,
|
||||
|
||||
holger krekel
|
||||
|
||||
Changes between 1.3.0 and 1.3.1
|
||||
==================================================
|
||||
|
||||
New features
|
||||
++++++++++++++++++
|
||||
|
||||
- issue91: introduce new py.test.xfail(reason) helper
|
||||
to imperatively mark a test as expected to fail. Can
|
||||
be used from within setup and test functions. This is
|
||||
useful especially for parametrized tests when certain
|
||||
configurations are expected-to-fail. In this case the
|
||||
declarative approach with the @py.test.mark.xfail cannot
|
||||
be used as it would mark all configurations as xfail.
|
||||
|
||||
- issue102: introduce new --maxfail=NUM option to stop
|
||||
test runs after NUM failures. This is a generalization
|
||||
of the '-x' or '--exitfirst' option which is now equivalent
|
||||
to '--maxfail=1'. Both '-x' and '--maxfail' will
|
||||
now also print a line near the end indicating the Interruption.
|
||||
|
||||
- issue89: allow py.test.mark decorators to be used on classes
|
||||
(class decorators were introduced with python2.6) and
|
||||
also allow to have multiple markers applied at class/module level
|
||||
by specifying a list.
|
||||
|
||||
- improve and refine letter reporting in the progress bar:
|
||||
. pass
|
||||
f failed test
|
||||
s skipped tests (reminder: use for dependency/platform mismatch only)
|
||||
x xfailed test (test that was expected to fail)
|
||||
X xpassed test (test that was expected to fail but passed)
|
||||
|
||||
You can use any combination of 'fsxX' with the '-r' extended
|
||||
reporting option. The xfail/xpass results will show up as
|
||||
skipped tests in the junitxml output - which also fixes
|
||||
issue99.
|
||||
|
||||
- make py.test.cmdline.main() return the exitstatus instead of raising
|
||||
SystemExit and also allow it to be called multiple times. This of
|
||||
course requires that your application and tests are properly teared
|
||||
down and don't have global state.
|
||||
|
||||
Fixes / Maintenance
|
||||
++++++++++++++++++++++
|
||||
|
||||
- improved traceback presentation:
|
||||
- improved and unified reporting for "--tb=short" option
|
||||
- Errors during test module imports are much shorter, (using --tb=short style)
|
||||
- raises shows shorter more relevant tracebacks
|
||||
- --fulltrace now more systematically makes traces longer / inhibits cutting
|
||||
|
||||
- improve support for raises and other dynamically compiled code by
|
||||
manipulating python's linecache.cache instead of the previous
|
||||
rather hacky way of creating custom code objects. This makes
|
||||
it seemlessly work on Jython and PyPy where it previously didn't.
|
||||
|
||||
- fix issue96: make capturing more resilient against Control-C
|
||||
interruptions (involved somewhat substantial refactoring
|
||||
to the underlying capturing functionality to avoid race
|
||||
conditions).
|
||||
|
||||
- fix chaining of conditional skipif/xfail decorators - so it works now
|
||||
as expected to use multiple @py.test.mark.skipif(condition) decorators,
|
||||
including specific reporting which of the conditions lead to skipping.
|
||||
|
||||
- fix issue95: late-import zlib so that it's not required
|
||||
for general py.test startup.
|
||||
|
||||
- fix issue94: make reporting more robust against bogus source code
|
||||
(and internally be more careful when presenting unexpected byte sequences)
|
||||
|
|
@ -1,720 +0,0 @@
|
|||
py.test/pylib 1.3.2: API and reporting refinements, many fixes
|
||||
===========================================================================
|
||||
|
||||
The pylib/py.test 1.3.2 release brings many bug fixes and some new
|
||||
features. It was refined for and tested against the recently released
|
||||
Python2.7 and remains compatibile to the usual armada of interpreters
|
||||
(Python2.4 through to Python3.1.2, Jython and PyPy). Note that for using
|
||||
distributed testing features you'll need to upgrade to the jointly released
|
||||
pytest-xdist-1.4 because of some internal refactorings.
|
||||
|
||||
See http://pytest.org for general documentation and below for
|
||||
a detailed CHANGELOG.
|
||||
|
||||
cheers & particular thanks to Benjamin Peterson, Ronny Pfannschmidt
|
||||
and all issue and patch contributors,
|
||||
|
||||
holger krekel
|
||||
|
||||
Changes between 1.3.1 and 1.3.2
|
||||
==================================================
|
||||
|
||||
New features
|
||||
++++++++++++++++++
|
||||
|
||||
- fix issue103: introduce py.test.raises as context manager, examples::
|
||||
|
||||
with py.test.raises(ZeroDivisionError):
|
||||
x = 0
|
||||
1 / x
|
||||
|
||||
with py.test.raises(RuntimeError) as excinfo:
|
||||
call_something()
|
||||
|
||||
# you may do extra checks on excinfo.value|type|traceback here
|
||||
|
||||
(thanks Ronny Pfannschmidt)
|
||||
|
||||
- Funcarg factories can now dynamically apply a marker to a
|
||||
test invocation. This is for example useful if a factory
|
||||
provides parameters to a test which are expected-to-fail::
|
||||
|
||||
def pytest_funcarg__arg(request):
|
||||
request.applymarker(py.test.mark.xfail(reason="flaky config"))
|
||||
...
|
||||
|
||||
def test_function(arg):
|
||||
...
|
||||
|
||||
- improved error reporting on collection and import errors. This makes
|
||||
use of a more general mechanism, namely that for custom test item/collect
|
||||
nodes ``node.repr_failure(excinfo)`` is now uniformly called so that you can
|
||||
override it to return a string error representation of your choice
|
||||
which is going to be reported as a (red) string.
|
||||
|
||||
- introduce '--junitprefix=STR' option to prepend a prefix
|
||||
to all reports in the junitxml file.
|
||||
|
||||
Bug fixes / Maintenance
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
- make tests and the ``pytest_recwarn`` plugin in particular fully compatible
|
||||
to Python2.7 (if you use the ``recwarn`` funcarg warnings will be enabled so that
|
||||
you can properly check for their existence in a cross-python manner).
|
||||
- refine --pdb: ignore xfailed tests, unify its TB-reporting and
|
||||
don't display failures again at the end.
|
||||
- fix assertion interpretation with the ** operator (thanks Benjamin Peterson)
|
||||
- fix issue105 assignment on the same line as a failing assertion (thanks Benjamin Peterson)
|
||||
- fix issue104 proper escaping for test names in junitxml plugin (thanks anonymous)
|
||||
- fix issue57 -f|--looponfail to work with xpassing tests (thanks Ronny)
|
||||
- fix issue92 collectonly reporter and --pastebin (thanks Benjamin Peterson)
|
||||
- fix py.code.compile(source) to generate unique filenames
|
||||
- fix assertion re-interp problems on PyPy, by defering code
|
||||
compilation to the (overridable) Frame.eval class. (thanks Amaury Forgeot)
|
||||
- fix py.path.local.pyimport() to work with directories
|
||||
- streamline py.path.local.mkdtemp implementation and usage
|
||||
- don't print empty lines when showing junitxml-filename
|
||||
- add optional boolean ignore_errors parameter to py.path.local.remove
|
||||
- fix terminal writing on win32/python2.4
|
||||
- py.process.cmdexec() now tries harder to return properly encoded unicode objects
|
||||
on all python versions
|
||||
- install plain py.test/py.which scripts also for Jython, this helps to
|
||||
get canonical script paths in virtualenv situations
|
||||
- make path.bestrelpath(path) return ".", note that when calling
|
||||
X.bestrelpath the assumption is that X is a directory.
|
||||
- make initial conftest discovery ignore "--" prefixed arguments
|
||||
- fix resultlog plugin when used in an multicpu/multihost xdist situation
|
||||
(thanks Jakub Gustak)
|
||||
- perform distributed testing related reporting in the xdist-plugin
|
||||
rather than having dist-related code in the generic py.test
|
||||
distribution
|
||||
- fix homedir detection on Windows
|
||||
- ship distribute_setup.py version 0.6.13
|
||||
|
||||
Changes between 1.3.0 and 1.3.1
|
||||
==================================================
|
||||
|
||||
New features
|
||||
++++++++++++++++++
|
||||
|
||||
- issue91: introduce new py.test.xfail(reason) helper
|
||||
to imperatively mark a test as expected to fail. Can
|
||||
be used from within setup and test functions. This is
|
||||
useful especially for parametrized tests when certain
|
||||
configurations are expected-to-fail. In this case the
|
||||
declarative approach with the @py.test.mark.xfail cannot
|
||||
be used as it would mark all configurations as xfail.
|
||||
|
||||
- issue102: introduce new --maxfail=NUM option to stop
|
||||
test runs after NUM failures. This is a generalization
|
||||
of the '-x' or '--exitfirst' option which is now equivalent
|
||||
to '--maxfail=1'. Both '-x' and '--maxfail' will
|
||||
now also print a line near the end indicating the Interruption.
|
||||
|
||||
- issue89: allow py.test.mark decorators to be used on classes
|
||||
(class decorators were introduced with python2.6) and
|
||||
also allow to have multiple markers applied at class/module level
|
||||
by specifying a list.
|
||||
|
||||
- improve and refine letter reporting in the progress bar:
|
||||
. pass
|
||||
f failed test
|
||||
s skipped tests (reminder: use for dependency/platform mismatch only)
|
||||
x xfailed test (test that was expected to fail)
|
||||
X xpassed test (test that was expected to fail but passed)
|
||||
|
||||
You can use any combination of 'fsxX' with the '-r' extended
|
||||
reporting option. The xfail/xpass results will show up as
|
||||
skipped tests in the junitxml output - which also fixes
|
||||
issue99.
|
||||
|
||||
- make py.test.cmdline.main() return the exitstatus instead of raising
|
||||
SystemExit and also allow it to be called multiple times. This of
|
||||
course requires that your application and tests are properly teared
|
||||
down and don't have global state.
|
||||
|
||||
Fixes / Maintenance
|
||||
++++++++++++++++++++++
|
||||
|
||||
- improved traceback presentation:
|
||||
- improved and unified reporting for "--tb=short" option
|
||||
- Errors during test module imports are much shorter, (using --tb=short style)
|
||||
- raises shows shorter more relevant tracebacks
|
||||
- --fulltrace now more systematically makes traces longer / inhibits cutting
|
||||
|
||||
- improve support for raises and other dynamically compiled code by
|
||||
manipulating python's linecache.cache instead of the previous
|
||||
rather hacky way of creating custom code objects. This makes
|
||||
it seemlessly work on Jython and PyPy where it previously didn't.
|
||||
|
||||
- fix issue96: make capturing more resilient against Control-C
|
||||
interruptions (involved somewhat substantial refactoring
|
||||
to the underlying capturing functionality to avoid race
|
||||
conditions).
|
||||
|
||||
- fix chaining of conditional skipif/xfail decorators - so it works now
|
||||
as expected to use multiple @py.test.mark.skipif(condition) decorators,
|
||||
including specific reporting which of the conditions lead to skipping.
|
||||
|
||||
- fix issue95: late-import zlib so that it's not required
|
||||
for general py.test startup.
|
||||
|
||||
- fix issue94: make reporting more robust against bogus source code
|
||||
(and internally be more careful when presenting unexpected byte sequences)
|
||||
|
||||
|
||||
Changes between 1.2.1 and 1.3.0
|
||||
==================================================
|
||||
|
||||
- deprecate --report option in favour of a new shorter and easier to
|
||||
remember -r option: it takes a string argument consisting of any
|
||||
combination of 'xfsX' characters. They relate to the single chars
|
||||
you see during the dotted progress printing and will print an extra line
|
||||
per test at the end of the test run. This extra line indicates the exact
|
||||
position or test ID that you directly paste to the py.test cmdline in order
|
||||
to re-run a particular test.
|
||||
|
||||
- allow external plugins to register new hooks via the new
|
||||
pytest_addhooks(pluginmanager) hook. The new release of
|
||||
the pytest-xdist plugin for distributed and looponfailing
|
||||
testing requires this feature.
|
||||
|
||||
- add a new pytest_ignore_collect(path, config) hook to allow projects and
|
||||
plugins to define exclusion behaviour for their directory structure -
|
||||
for example you may define in a conftest.py this method::
|
||||
|
||||
def pytest_ignore_collect(path):
|
||||
return path.check(link=1)
|
||||
|
||||
to prevent even a collection try of any tests in symlinked dirs.
|
||||
|
||||
- new pytest_pycollect_makemodule(path, parent) hook for
|
||||
allowing customization of the Module collection object for a
|
||||
matching test module.
|
||||
|
||||
- extend and refine xfail mechanism:
|
||||
``@py.test.mark.xfail(run=False)`` do not run the decorated test
|
||||
``@py.test.mark.xfail(reason="...")`` prints the reason string in xfail summaries
|
||||
specifiying ``--runxfail`` on command line virtually ignores xfail markers
|
||||
|
||||
- expose (previously internal) commonly useful methods:
|
||||
py.io.get_terminal_with() -> return terminal width
|
||||
py.io.ansi_print(...) -> print colored/bold text on linux/win32
|
||||
py.io.saferepr(obj) -> return limited representation string
|
||||
|
||||
- expose test outcome related exceptions as py.test.skip.Exception,
|
||||
py.test.raises.Exception etc., useful mostly for plugins
|
||||
doing special outcome interpretation/tweaking
|
||||
|
||||
- (issue85) fix junitxml plugin to handle tests with non-ascii output
|
||||
|
||||
- fix/refine python3 compatibility (thanks Benjamin Peterson)
|
||||
|
||||
- fixes for making the jython/win32 combination work, note however:
|
||||
jython2.5.1/win32 does not provide a command line launcher, see
|
||||
http://bugs.jython.org/issue1491 . See pylib install documentation
|
||||
for how to work around.
|
||||
|
||||
- fixes for handling of unicode exception values and unprintable objects
|
||||
|
||||
- (issue87) fix unboundlocal error in assertionold code
|
||||
|
||||
- (issue86) improve documentation for looponfailing
|
||||
|
||||
- refine IO capturing: stdin-redirect pseudo-file now has a NOP close() method
|
||||
|
||||
- ship distribute_setup.py version 0.6.10
|
||||
|
||||
- added links to the new capturelog and coverage plugins
|
||||
|
||||
|
||||
Changes between 1.2.1 and 1.2.0
|
||||
=====================================
|
||||
|
||||
- refined usage and options for "py.cleanup"::
|
||||
|
||||
py.cleanup # remove "*.pyc" and "*$py.class" (jython) files
|
||||
py.cleanup -e .swp -e .cache # also remove files with these extensions
|
||||
py.cleanup -s # remove "build" and "dist" directory next to setup.py files
|
||||
py.cleanup -d # also remove empty directories
|
||||
py.cleanup -a # synonym for "-s -d -e 'pip-log.txt'"
|
||||
py.cleanup -n # dry run, only show what would be removed
|
||||
|
||||
- add a new option "py.test --funcargs" which shows available funcargs
|
||||
and their help strings (docstrings on their respective factory function)
|
||||
for a given test path
|
||||
|
||||
- display a short and concise traceback if a funcarg lookup fails
|
||||
|
||||
- early-load "conftest.py" files in non-dot first-level sub directories.
|
||||
allows to conveniently keep and access test-related options in a ``test``
|
||||
subdir and still add command line options.
|
||||
|
||||
- fix issue67: new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value
|
||||
|
||||
- fix issue78: always call python-level teardown functions even if the
|
||||
according setup failed. This includes refinements for calling setup_module/class functions
|
||||
which will now only be called once instead of the previous behaviour where they'd be called
|
||||
multiple times if they raise an exception (including a Skipped exception). Any exception
|
||||
will be re-corded and associated with all tests in the according module/class scope.
|
||||
|
||||
- fix issue63: assume <40 columns to be a bogus terminal width, default to 80
|
||||
|
||||
- fix pdb debugging to be in the correct frame on raises-related errors
|
||||
|
||||
- update apipkg.py to fix an issue where recursive imports might
|
||||
unnecessarily break importing
|
||||
|
||||
- fix plugin links
|
||||
|
||||
Changes between 1.2 and 1.1.1
|
||||
=====================================
|
||||
|
||||
- moved dist/looponfailing from py.test core into a new
|
||||
separately released pytest-xdist plugin.
|
||||
|
||||
- new junitxml plugin: --junitxml=path will generate a junit style xml file
|
||||
which is processable e.g. by the Hudson CI system.
|
||||
|
||||
- new option: --genscript=path will generate a standalone py.test script
|
||||
which will not need any libraries installed. thanks to Ralf Schmitt.
|
||||
|
||||
- new option: --ignore will prevent specified path from collection.
|
||||
Can be specified multiple times.
|
||||
|
||||
- new option: --confcutdir=dir will make py.test only consider conftest
|
||||
files that are relative to the specified dir.
|
||||
|
||||
- new funcarg: "pytestconfig" is the pytest config object for access
|
||||
to command line args and can now be easily used in a test.
|
||||
|
||||
- install 'py.test' and `py.which` with a ``-$VERSION`` suffix to
|
||||
disambiguate between Python3, python2.X, Jython and PyPy installed versions.
|
||||
|
||||
- new "pytestconfig" funcarg allows access to test config object
|
||||
|
||||
- new "pytest_report_header" hook can return additional lines
|
||||
to be displayed at the header of a test run.
|
||||
|
||||
- (experimental) allow "py.test path::name1::name2::..." for pointing
|
||||
to a test within a test collection directly. This might eventually
|
||||
evolve as a full substitute to "-k" specifications.
|
||||
|
||||
- streamlined plugin loading: order is now as documented in
|
||||
customize.html: setuptools, ENV, commandline, conftest.
|
||||
also setuptools entry point names are turned to canonical namees ("pytest_*")
|
||||
|
||||
- automatically skip tests that need 'capfd' but have no os.dup
|
||||
|
||||
- allow pytest_generate_tests to be defined in classes as well
|
||||
|
||||
- deprecate usage of 'disabled' attribute in favour of pytestmark
|
||||
- deprecate definition of Directory, Module, Class and Function nodes
|
||||
in conftest.py files. Use pytest collect hooks instead.
|
||||
|
||||
- collection/item node specific runtest/collect hooks are only called exactly
|
||||
on matching conftest.py files, i.e. ones which are exactly below
|
||||
the filesystem path of an item
|
||||
|
||||
- change: the first pytest_collect_directory hook to return something
|
||||
will now prevent further hooks to be called.
|
||||
|
||||
- change: figleaf plugin now requires --figleaf to run. Also
|
||||
change its long command line options to be a bit shorter (see py.test -h).
|
||||
|
||||
- change: pytest doctest plugin is now enabled by default and has a
|
||||
new option --doctest-glob to set a pattern for file matches.
|
||||
|
||||
- change: remove internal py._* helper vars, only keep py._pydir
|
||||
|
||||
- robustify capturing to survive if custom pytest_runtest_setup
|
||||
code failed and prevented the capturing setup code from running.
|
||||
|
||||
- make py.test.* helpers provided by default plugins visible early -
|
||||
works transparently both for pydoc and for interactive sessions
|
||||
which will regularly see e.g. py.test.mark and py.test.importorskip.
|
||||
|
||||
- simplify internal plugin manager machinery
|
||||
- simplify internal collection tree by introducing a RootCollector node
|
||||
|
||||
- fix assert reinterpreation that sees a call containing "keyword=..."
|
||||
|
||||
- fix issue66: invoke pytest_sessionstart and pytest_sessionfinish
|
||||
hooks on slaves during dist-testing, report module/session teardown
|
||||
hooks correctly.
|
||||
|
||||
- fix issue65: properly handle dist-testing if no
|
||||
execnet/py lib installed remotely.
|
||||
|
||||
- skip some install-tests if no execnet is available
|
||||
|
||||
- fix docs, fix internal bin/ script generation
|
||||
|
||||
|
||||
Changes between 1.1.1 and 1.1.0
|
||||
=====================================
|
||||
|
||||
- introduce automatic plugin registration via 'pytest11'
|
||||
entrypoints via setuptools' pkg_resources.iter_entry_points
|
||||
|
||||
- fix py.test dist-testing to work with execnet >= 1.0.0b4
|
||||
|
||||
- re-introduce py.test.cmdline.main() for better backward compatibility
|
||||
|
||||
- svn paths: fix a bug with path.check(versioned=True) for svn paths,
|
||||
allow '%' in svn paths, make svnwc.update() default to interactive mode
|
||||
like in 1.0.x and add svnwc.update(interactive=False) to inhibit interaction.
|
||||
|
||||
- refine distributed tarball to contain test and no pyc files
|
||||
|
||||
- try harder to have deprecation warnings for py.compat.* accesses
|
||||
report a correct location
|
||||
|
||||
Changes between 1.1.0 and 1.0.2
|
||||
=====================================
|
||||
|
||||
* adjust and improve docs
|
||||
|
||||
* remove py.rest tool and internal namespace - it was
|
||||
never really advertised and can still be used with
|
||||
the old release if needed. If there is interest
|
||||
it could be revived into its own tool i guess.
|
||||
|
||||
* fix issue48 and issue59: raise an Error if the module
|
||||
from an imported test file does not seem to come from
|
||||
the filepath - avoids "same-name" confusion that has
|
||||
been reported repeatedly
|
||||
|
||||
* merged Ronny's nose-compatibility hacks: now
|
||||
nose-style setup_module() and setup() functions are
|
||||
supported
|
||||
|
||||
* introduce generalized py.test.mark function marking
|
||||
|
||||
* reshuffle / refine command line grouping
|
||||
|
||||
* deprecate parser.addgroup in favour of getgroup which creates option group
|
||||
|
||||
* add --report command line option that allows to control showing of skipped/xfailed sections
|
||||
|
||||
* generalized skipping: a new way to mark python functions with skipif or xfail
|
||||
at function, class and modules level based on platform or sys-module attributes.
|
||||
|
||||
* extend py.test.mark decorator to allow for positional args
|
||||
|
||||
* introduce and test "py.cleanup -d" to remove empty directories
|
||||
|
||||
* fix issue #59 - robustify unittest test collection
|
||||
|
||||
* make bpython/help interaction work by adding an __all__ attribute
|
||||
to ApiModule, cleanup initpkg
|
||||
|
||||
* use MIT license for pylib, add some contributors
|
||||
|
||||
* remove py.execnet code and substitute all usages with 'execnet' proper
|
||||
|
||||
* fix issue50 - cached_setup now caches more to expectations
|
||||
for test functions with multiple arguments.
|
||||
|
||||
* merge Jarko's fixes, issue #45 and #46
|
||||
|
||||
* add the ability to specify a path for py.lookup to search in
|
||||
|
||||
* fix a funcarg cached_setup bug probably only occuring
|
||||
in distributed testing and "module" scope with teardown.
|
||||
|
||||
* many fixes and changes for making the code base python3 compatible,
|
||||
many thanks to Benjamin Peterson for helping with this.
|
||||
|
||||
* consolidate builtins implementation to be compatible with >=2.3,
|
||||
add helpers to ease keeping 2 and 3k compatible code
|
||||
|
||||
* deprecate py.compat.doctest|subprocess|textwrap|optparse
|
||||
|
||||
* deprecate py.magic.autopath, remove py/magic directory
|
||||
|
||||
* move pytest assertion handling to py/code and a pytest_assertion
|
||||
plugin, add "--no-assert" option, deprecate py.magic namespaces
|
||||
in favour of (less) py.code ones.
|
||||
|
||||
* consolidate and cleanup py/code classes and files
|
||||
|
||||
* cleanup py/misc, move tests to bin-for-dist
|
||||
|
||||
* introduce delattr/delitem/delenv methods to py.test's monkeypatch funcarg
|
||||
|
||||
* consolidate py.log implementation, remove old approach.
|
||||
|
||||
* introduce py.io.TextIO and py.io.BytesIO for distinguishing between
|
||||
text/unicode and byte-streams (uses underlying standard lib io.*
|
||||
if available)
|
||||
|
||||
* make py.unittest_convert helper script available which converts "unittest.py"
|
||||
style files into the simpler assert/direct-test-classes py.test/nosetests
|
||||
style. The script was written by Laura Creighton.
|
||||
|
||||
* simplified internal localpath implementation
|
||||
|
||||
Changes between 1.0.1 and 1.0.2
|
||||
=====================================
|
||||
|
||||
* fixing packaging issues, triggered by fedora redhat packaging,
|
||||
also added doc, examples and contrib dirs to the tarball.
|
||||
|
||||
* added a documentation link to the new django plugin.
|
||||
|
||||
Changes between 1.0.0 and 1.0.1
|
||||
=====================================
|
||||
|
||||
* added a 'pytest_nose' plugin which handles nose.SkipTest,
|
||||
nose-style function/method/generator setup/teardown and
|
||||
tries to report functions correctly.
|
||||
|
||||
* capturing of unicode writes or encoded strings to sys.stdout/err
|
||||
work better, also terminalwriting was adapted and somewhat
|
||||
unified between windows and linux.
|
||||
|
||||
* improved documentation layout and content a lot
|
||||
|
||||
* added a "--help-config" option to show conftest.py / ENV-var names for
|
||||
all longopt cmdline options, and some special conftest.py variables.
|
||||
renamed 'conf_capture' conftest setting to 'option_capture' accordingly.
|
||||
|
||||
* fix issue #27: better reporting on non-collectable items given on commandline
|
||||
(e.g. pyc files)
|
||||
|
||||
* fix issue #33: added --version flag (thanks Benjamin Peterson)
|
||||
|
||||
* fix issue #32: adding support for "incomplete" paths to wcpath.status()
|
||||
|
||||
* "Test" prefixed classes are *not* collected by default anymore if they
|
||||
have an __init__ method
|
||||
|
||||
* monkeypatch setenv() now accepts a "prepend" parameter
|
||||
|
||||
* improved reporting of collection error tracebacks
|
||||
|
||||
* simplified multicall mechanism and plugin architecture,
|
||||
renamed some internal methods and argnames
|
||||
|
||||
Changes between 1.0.0b9 and 1.0.0
|
||||
=====================================
|
||||
|
||||
* more terse reporting try to show filesystem path relatively to current dir
|
||||
* improve xfail output a bit
|
||||
|
||||
Changes between 1.0.0b8 and 1.0.0b9
|
||||
=====================================
|
||||
|
||||
* cleanly handle and report final teardown of test setup
|
||||
|
||||
* fix svn-1.6 compat issue with py.path.svnwc().versioned()
|
||||
(thanks Wouter Vanden Hove)
|
||||
|
||||
* setup/teardown or collection problems now show as ERRORs
|
||||
or with big "E"'s in the progress lines. they are reported
|
||||
and counted separately.
|
||||
|
||||
* dist-testing: properly handle test items that get locally
|
||||
collected but cannot be collected on the remote side - often
|
||||
due to platform/dependency reasons
|
||||
|
||||
* simplified py.test.mark API - see keyword plugin documentation
|
||||
|
||||
* integrate better with logging: capturing now by default captures
|
||||
test functions and their immediate setup/teardown in a single stream
|
||||
|
||||
* capsys and capfd funcargs now have a readouterr() and a close() method
|
||||
(underlyingly py.io.StdCapture/FD objects are used which grew a
|
||||
readouterr() method as well to return snapshots of captured out/err)
|
||||
|
||||
* make assert-reinterpretation work better with comparisons not
|
||||
returning bools (reported with numpy from thanks maciej fijalkowski)
|
||||
|
||||
* reworked per-test output capturing into the pytest_iocapture.py plugin
|
||||
and thus removed capturing code from config object
|
||||
|
||||
* item.repr_failure(excinfo) instead of item.repr_failure(excinfo, outerr)
|
||||
|
||||
|
||||
Changes between 1.0.0b7 and 1.0.0b8
|
||||
=====================================
|
||||
|
||||
* pytest_unittest-plugin is now enabled by default
|
||||
|
||||
* introduced pytest_keyboardinterrupt hook and
|
||||
refined pytest_sessionfinish hooked, added tests.
|
||||
|
||||
* workaround a buggy logging module interaction ("closing already closed
|
||||
files"). Thanks to Sridhar Ratnakumar for triggering.
|
||||
|
||||
* if plugins use "py.test.importorskip" for importing
|
||||
a dependency only a warning will be issued instead
|
||||
of exiting the testing process.
|
||||
|
||||
* many improvements to docs:
|
||||
- refined funcargs doc , use the term "factory" instead of "provider"
|
||||
- added a new talk/tutorial doc page
|
||||
- better download page
|
||||
- better plugin docstrings
|
||||
- added new plugins page and automatic doc generation script
|
||||
|
||||
* fixed teardown problem related to partially failing funcarg setups
|
||||
(thanks MrTopf for reporting), "pytest_runtest_teardown" is now
|
||||
always invoked even if the "pytest_runtest_setup" failed.
|
||||
|
||||
* tweaked doctest output for docstrings in py modules,
|
||||
thanks Radomir.
|
||||
|
||||
Changes between 1.0.0b3 and 1.0.0b7
|
||||
=============================================
|
||||
|
||||
* renamed py.test.xfail back to py.test.mark.xfail to avoid
|
||||
two ways to decorate for xfail
|
||||
|
||||
* re-added py.test.mark decorator for setting keywords on functions
|
||||
(it was actually documented so removing it was not nice)
|
||||
|
||||
* remove scope-argument from request.addfinalizer() because
|
||||
request.cached_setup has the scope arg. TOOWTDI.
|
||||
|
||||
* perform setup finalization before reporting failures
|
||||
|
||||
* apply modified patches from Andreas Kloeckner to allow
|
||||
test functions to have no func_code (#22) and to make
|
||||
"-k" and function keywords work (#20)
|
||||
|
||||
* apply patch from Daniel Peolzleithner (issue #23)
|
||||
|
||||
* resolve issue #18, multiprocessing.Manager() and
|
||||
redirection clash
|
||||
|
||||
* make __name__ == "__channelexec__" for remote_exec code
|
||||
|
||||
Changes between 1.0.0b1 and 1.0.0b3
|
||||
=============================================
|
||||
|
||||
* plugin classes are removed: one now defines
|
||||
hooks directly in conftest.py or global pytest_*.py
|
||||
files.
|
||||
|
||||
* added new pytest_namespace(config) hook that allows
|
||||
to inject helpers directly to the py.test.* namespace.
|
||||
|
||||
* documented and refined many hooks
|
||||
|
||||
* added new style of generative tests via
|
||||
pytest_generate_tests hook that integrates
|
||||
well with function arguments.
|
||||
|
||||
|
||||
Changes between 0.9.2 and 1.0.0b1
|
||||
=============================================
|
||||
|
||||
* introduced new "funcarg" setup method,
|
||||
see doc/test/funcarg.txt
|
||||
|
||||
* introduced plugin architecuture and many
|
||||
new py.test plugins, see
|
||||
doc/test/plugins.txt
|
||||
|
||||
* teardown_method is now guaranteed to get
|
||||
called after a test method has run.
|
||||
|
||||
* new method: py.test.importorskip(mod,minversion)
|
||||
will either import or call py.test.skip()
|
||||
|
||||
* completely revised internal py.test architecture
|
||||
|
||||
* new py.process.ForkedFunc object allowing to
|
||||
fork execution of a function to a sub process
|
||||
and getting a result back.
|
||||
|
||||
XXX lots of things missing here XXX
|
||||
|
||||
Changes between 0.9.1 and 0.9.2
|
||||
===============================
|
||||
|
||||
* refined installation and metadata, created new setup.py,
|
||||
now based on setuptools/ez_setup (thanks to Ralf Schmitt
|
||||
for his support).
|
||||
|
||||
* improved the way of making py.* scripts available in
|
||||
windows environments, they are now added to the
|
||||
Scripts directory as ".cmd" files.
|
||||
|
||||
* py.path.svnwc.status() now is more complete and
|
||||
uses xml output from the 'svn' command if available
|
||||
(Guido Wesdorp)
|
||||
|
||||
* fix for py.path.svn* to work with svn 1.5
|
||||
(Chris Lamb)
|
||||
|
||||
* fix path.relto(otherpath) method on windows to
|
||||
use normcase for checking if a path is relative.
|
||||
|
||||
* py.test's traceback is better parseable from editors
|
||||
(follows the filenames:LINENO: MSG convention)
|
||||
(thanks to Osmo Salomaa)
|
||||
|
||||
* fix to javascript-generation, "py.test --runbrowser"
|
||||
should work more reliably now
|
||||
|
||||
* removed previously accidentally added
|
||||
py.test.broken and py.test.notimplemented helpers.
|
||||
|
||||
* there now is a py.__version__ attribute
|
||||
|
||||
Changes between 0.9.0 and 0.9.1
|
||||
===============================
|
||||
|
||||
This is a fairly complete list of changes between 0.9 and 0.9.1, which can
|
||||
serve as a reference for developers.
|
||||
|
||||
* allowing + signs in py.path.svn urls [39106]
|
||||
* fixed support for Failed exceptions without excinfo in py.test [39340]
|
||||
* added support for killing processes for Windows (as well as platforms that
|
||||
support os.kill) in py.misc.killproc [39655]
|
||||
* added setup/teardown for generative tests to py.test [40702]
|
||||
* added detection of FAILED TO LOAD MODULE to py.test [40703, 40738, 40739]
|
||||
* fixed problem with calling .remove() on wcpaths of non-versioned files in
|
||||
py.path [44248]
|
||||
* fixed some import and inheritance issues in py.test [41480, 44648, 44655]
|
||||
* fail to run greenlet tests when pypy is available, but without stackless
|
||||
[45294]
|
||||
* small fixes in rsession tests [45295]
|
||||
* fixed issue with 2.5 type representations in py.test [45483, 45484]
|
||||
* made that internal reporting issues displaying is done atomically in py.test
|
||||
[45518]
|
||||
* made that non-existing files are igored by the py.lookup script [45519]
|
||||
* improved exception name creation in py.test [45535]
|
||||
* made that less threads are used in execnet [merge in 45539]
|
||||
* removed lock required for atomical reporting issue displaying in py.test
|
||||
[45545]
|
||||
* removed globals from execnet [45541, 45547]
|
||||
* refactored cleanup mechanics, made that setDaemon is set to 1 to make atexit
|
||||
get called in 2.5 (py.execnet) [45548]
|
||||
* fixed bug in joining threads in py.execnet's servemain [45549]
|
||||
* refactored py.test.rsession tests to not rely on exact output format anymore
|
||||
[45646]
|
||||
* using repr() on test outcome [45647]
|
||||
* added 'Reason' classes for py.test.skip() [45648, 45649]
|
||||
* killed some unnecessary sanity check in py.test.collect [45655]
|
||||
* avoid using os.tmpfile() in py.io.fdcapture because on Windows it's only
|
||||
usable by Administrators [45901]
|
||||
* added support for locking and non-recursive commits to py.path.svnwc [45994]
|
||||
* locking files in py.execnet to prevent CPython from segfaulting [46010]
|
||||
* added export() method to py.path.svnurl
|
||||
* fixed -d -x in py.test [47277]
|
||||
* fixed argument concatenation problem in py.path.svnwc [49423]
|
||||
* restore py.test behaviour that it exits with code 1 when there are failures
|
||||
[49974]
|
||||
* don't fail on html files that don't have an accompanying .txt file [50606]
|
||||
* fixed 'utestconvert.py < input' [50645]
|
||||
* small fix for code indentation in py.code.source [50755]
|
||||
* fix _docgen.py documentation building [51285]
|
||||
* improved checks for source representation of code blocks in py.test [51292]
|
||||
* added support for passing authentication to py.path.svn* objects [52000,
|
||||
52001]
|
||||
* removed sorted() call for py.apigen tests in favour of [].sort() to support
|
||||
Python 2.3 [52481]
|
|
@ -1,26 +0,0 @@
|
|||
py.test/pylib 1.3.3: windows and other fixes
|
||||
===========================================================================
|
||||
|
||||
pylib/py.test 1.3.3 is a minor bugfix release featuring some improvements
|
||||
and fixes. See changelog_ for full history.
|
||||
|
||||
have fun,
|
||||
holger krekel
|
||||
|
||||
.. _changelog: ../changelog.html
|
||||
|
||||
Changes between 1.3.2 and 1.3.3
|
||||
==================================================
|
||||
|
||||
- fix issue113: assertion representation problem with triple-quoted strings
|
||||
(and possibly other cases)
|
||||
- make conftest loading detect that a conftest file with the same
|
||||
content was already loaded, avoids surprises in nested directory structures
|
||||
which can be produced e.g. by Hudson. It probably removes the need to use
|
||||
--confcutdir in most cases.
|
||||
- fix terminal coloring for win32
|
||||
(thanks Michael Foord for reporting)
|
||||
- fix weirdness: make terminal width detection work on stdout instead of stdin
|
||||
(thanks Armin Ronacher for reporting)
|
||||
- remove trailing whitespace in all py/text distribution files
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
py.test/pylib 1.3.4: fixes and new native traceback option
|
||||
===========================================================================
|
||||
|
||||
pylib/py.test 1.3.4 is a minor maintenance release mostly containing bug fixes
|
||||
and a new "--tb=native" traceback option to show "normal" Python standard
|
||||
tracebacks instead of the py.test enhanced tracebacks. See below for more
|
||||
change info and http://pytest.org for more general information on features
|
||||
and configuration of the testing tool.
|
||||
|
||||
Thanks to the issue reporters and generally to Ronny Pfannschmidt for help.
|
||||
|
||||
cheers,
|
||||
holger krekel
|
||||
|
||||
Changes between 1.3.3 and 1.3.4
|
||||
==================================================
|
||||
|
||||
- fix issue111: improve install documentation for windows
|
||||
- fix issue119: fix custom collectability of __init__.py as a module
|
||||
- fix issue116: --doctestmodules work with __init__.py files as well
|
||||
- fix issue115: unify internal exception passthrough/catching/GeneratorExit
|
||||
- fix issue118: new --tb=native for presenting cpython-standard exceptions
|
|
@ -126,46 +126,4 @@ Important Notes
|
|||
if a certain dependency or command line option is missing.
|
||||
|
||||
|
||||
More Detailed Changes between 1.3.4 and 2.0.0
|
||||
==================================================
|
||||
|
||||
- pytest-2.0 is now its own package and depends on pylib-2.0
|
||||
- new ability: python -m pytest / python -m pytest.main ability
|
||||
- new python invcation: pytest.main(args, plugins) to load
|
||||
some custom plugins early.
|
||||
- try harder to run unittest test suites in a more compatible manner
|
||||
by deferring setup/teardown semantics to the unittest package.
|
||||
- introduce a new way to set config options via ini-style files,
|
||||
by default setup.cfg and tox.ini files are searched. The old
|
||||
ways (certain environment variables, dynamic conftest.py reading
|
||||
is removed).
|
||||
- add a new "-q" option which decreases verbosity and prints a more
|
||||
nose/unittest-style "dot" output.
|
||||
- fix issue135 - marks now work with unittest test cases as well
|
||||
- fix issue126 - introduce py.test.set_trace() to trace execution via
|
||||
PDB during the running of tests even if capturing is ongoing.
|
||||
- fix issue123 - new "python -m py.test" invocation for py.test
|
||||
(requires Python 2.5 or above)
|
||||
- fix issue124 - make reporting more resilient against tests opening
|
||||
files on filedescriptor 1 (stdout).
|
||||
- fix issue109 - sibling conftest.py files will not be loaded.
|
||||
(and Directory collectors cannot be customized anymore from a Directory's
|
||||
conftest.py - this needs to happen at least one level up).
|
||||
- introduce (customizable) assertion failure representations and enhance
|
||||
output on assertion failures for comparisons and other cases (Floris Bruynooghe)
|
||||
- nose-plugin: pass through type-signature failures in setup/teardown
|
||||
functions instead of not calling them (Ed Singleton)
|
||||
- remove py.test.collect.Directory (follows from a major refactoring
|
||||
and simplification of the collection process)
|
||||
- majorly reduce py.test core code, shift function/python testing to own plugin
|
||||
- fix issue88 (finding custom test nodes from command line arg)
|
||||
- refine 'tmpdir' creation, will now create basenames better associated
|
||||
with test names (thanks Ronny)
|
||||
- "xpass" (unexpected pass) tests don't cause exitcode!=0
|
||||
- fix issue131 / issue60 - importing doctests in __init__ files used as namespace packages
|
||||
- fix issue93 stdout/stderr is captured while importing conftest.py
|
||||
- fix bug: unittest collected functions now also can have "pytestmark"
|
||||
applied at class/module level
|
||||
- add ability to use "class" level for cached_setup helper
|
||||
- fix strangeness: mark.* objects are now immutable, create new instances
|
||||
|
||||
see :ref:`changelog` for more detailed changes.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
py.test reference documentation
|
||||
================================================
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
Writing and reporting of assertions in tests
|
||||
============================================
|
||||
|
||||
.. _`assert with the assert statement`:
|
||||
|
||||
assert with the ``assert`` statement
|
||||
---------------------------------------------------------
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ builtin function arguments
|
|||
-----------------------------------------------------
|
||||
|
||||
You can ask for available builtin or project-custom
|
||||
:ref:`function arguments` by typing::
|
||||
:ref:`function arguments <funcargs>` by typing::
|
||||
|
||||
$ py.test --funcargs
|
||||
pytestconfig
|
||||
|
|
|
@ -17,14 +17,14 @@ Setting capturing methods or disabling capturing
|
|||
|
||||
There are two ways in which ``py.test`` can perform capturing:
|
||||
|
||||
* ``fd`` level capturing (default): All writes going to the operating
|
||||
system file descriptors 1 and 2 will be captured, for example writes such
|
||||
as ``os.write(1, 'hello')``. Capturing on ``fd``-level also includes
|
||||
* ``fd`` level capturing (default): All writes going to the operating
|
||||
system file descriptors 1 and 2 will be captured, for example writes such
|
||||
as ``os.write(1, 'hello')``. Capturing on ``fd``-level also includes
|
||||
**output from subprocesses**.
|
||||
|
||||
* ``sys`` level capturing: The ``sys.stdout`` and ``sys.stderr`` will
|
||||
* ``sys`` level capturing: The ``sys.stdout`` and ``sys.stderr`` will
|
||||
will be replaced with in-memory files and the ``print`` builtin or
|
||||
output from code like ``sys.stderr.write(...)`` will be captured with
|
||||
output from code like ``sys.stderr.write(...)`` will be captured with
|
||||
this method.
|
||||
|
||||
.. _`disable capturing`:
|
||||
|
@ -42,6 +42,8 @@ If you set capturing values in a conftest file like this::
|
|||
|
||||
then all tests in that directory will execute with "fd" style capturing.
|
||||
|
||||
_ `printdebugging`:
|
||||
|
||||
Accessing captured output from a test function
|
||||
---------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
.. _changelog:
|
||||
|
||||
Changelog history
|
||||
=================================
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@ html_sidebars = {'index': 'indexsidebar.html'}
|
|||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
#html_additional_pages = {'index': 'index.html'}
|
||||
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
|
|
@ -15,7 +15,8 @@ Contact channels
|
|||
|
||||
- #pylib on irc.freenode.net IRC channel for random questions.
|
||||
|
||||
- `tetamap`_: Holger Krekel's blog, often about testing and py.test related news.
|
||||
- private mail to Holger.Krekel at gmail com if you have sensitive issues to communicate
|
||||
|
||||
- `commit mailing list`_
|
||||
|
||||
- `merlinux.eu`_ offers on-site teaching and consulting services.
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
.. _toc:
|
||||
|
||||
Table of Contents
|
||||
========================
|
||||
|
||||
.. note::
|
||||
version 2.0 introduces :ref:`pytest as the main Python import name <naming20>`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
overview
|
||||
apiref
|
||||
plugins
|
||||
example/index
|
||||
talks
|
||||
develop
|
||||
announce/index
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
changelog.txt
|
||||
naming20.txt
|
||||
example/attic
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
|
@ -11,6 +11,7 @@ You can get help on options and ini-config values by running::
|
|||
This will display command line and configuration file settings
|
||||
which were registered by installed plugins.
|
||||
|
||||
|
||||
how test configuration is read from setup/tox ini-files
|
||||
--------------------------------------------------------
|
||||
|
||||
|
@ -40,6 +41,26 @@ will look in the following dirs for a config file::
|
|||
If argument is provided to a py.test run, the current working directory
|
||||
is used to start the search.
|
||||
|
||||
.. _`how to change command line options defaults`:
|
||||
.. _`adding default options`:
|
||||
|
||||
how to change command line options defaults
|
||||
------------------------------------------------
|
||||
|
||||
py.test provides a simple way to set some default
|
||||
command line options. For example, if you want
|
||||
to always see detailed info on skipped and xfailed
|
||||
tests, as well as have terser "dot progress output",
|
||||
you can add this to your root directory::
|
||||
|
||||
# content of pytest.ini
|
||||
# (or tox.ini or setup.cfg)
|
||||
[pytest]
|
||||
addopts = -rsxX -q
|
||||
|
||||
From now on, running ``py.test`` will implicitely add
|
||||
the specified options.
|
||||
|
||||
builtin configuration file options
|
||||
----------------------------------------------
|
||||
|
||||
|
@ -86,18 +107,20 @@ builtin configuration file options
|
|||
This would tell py.test to not recurse into typical subversion or
|
||||
sphinx-build directories or into any ``tmp`` prefixed directory.
|
||||
|
||||
.. confval:: python_discovery
|
||||
.. confval:: python_files
|
||||
|
||||
Determines names and patterns for finding Python tests, specified
|
||||
through indendent ``name = value`` settings with these possible names::
|
||||
One or more Glob-style file patterns determining which python files
|
||||
are considered as test modules.
|
||||
|
||||
[pytest]
|
||||
python_discovery =
|
||||
file = <glob-pattern> <glob-pattern>
|
||||
func = <function-or-method-name-prefix>
|
||||
class = <class-name-prefix>
|
||||
.. confval:: python_classes
|
||||
|
||||
See :ref:`change naming conventions` for examples. the ``class``
|
||||
to be empty in which case all non-underscore empty classes
|
||||
will be considered.
|
||||
One or more name prefixes determining which test classes
|
||||
are considered as test modules.
|
||||
|
||||
.. confval:: python_functions
|
||||
|
||||
One or more name prefixes determining which test functions
|
||||
and methods are considered as test modules.
|
||||
|
||||
See :ref:`change naming conventions` for examples.
|
||||
|
||||
|
|
|
@ -15,15 +15,12 @@ Working from version control or a tarball
|
|||
To follow development or start experiments, checkout the
|
||||
complete code and documentation source with mercurial_::
|
||||
|
||||
hg clone https://bitbucket.org/hpk42/py-trunk/
|
||||
|
||||
Development takes place on the 'trunk' branch.
|
||||
hg clone https://bitbucket.org/hpk42/pytest/
|
||||
|
||||
You can also go to the python package index and
|
||||
download and unpack a TAR file::
|
||||
|
||||
http://pypi.python.org/pypi/py/
|
||||
|
||||
http://pypi.python.org/pypi/pytest/
|
||||
|
||||
activating a checkout with setuptools
|
||||
--------------------------------------------
|
||||
|
|
|
@ -37,87 +37,6 @@ class TestFailing(object):
|
|||
return 42
|
||||
assert not f()
|
||||
|
||||
def test_complex_error(self):
|
||||
def f():
|
||||
return 44
|
||||
def g():
|
||||
return 43
|
||||
somefunc(f(), g())
|
||||
|
||||
def test_z1_unpack_error(self):
|
||||
l = []
|
||||
a,b = l
|
||||
|
||||
def test_z2_type_error(self):
|
||||
l = 3
|
||||
a,b = l
|
||||
|
||||
def test_startswith(self):
|
||||
s = "123"
|
||||
g = "456"
|
||||
assert s.startswith(g)
|
||||
|
||||
def test_startswith_nested(self):
|
||||
def f():
|
||||
return "123"
|
||||
def g():
|
||||
return "456"
|
||||
assert f().startswith(g())
|
||||
|
||||
def test_global_func(self):
|
||||
assert isinstance(globf(42), float)
|
||||
|
||||
def test_instance(self):
|
||||
self.x = 6*7
|
||||
assert self.x != 42
|
||||
|
||||
def test_compare(self):
|
||||
assert globf(10) < 5
|
||||
|
||||
def test_try_finally(self):
|
||||
x = 1
|
||||
try:
|
||||
assert x == 0
|
||||
finally:
|
||||
x = 0
|
||||
|
||||
def test_raises(self):
|
||||
s = 'qwe'
|
||||
raises(TypeError, "int(s)")
|
||||
|
||||
def test_raises_doesnt(self):
|
||||
raises(IOError, "int('3')")
|
||||
|
||||
def test_raise(self):
|
||||
raise ValueError("demo error")
|
||||
|
||||
def test_tupleerror(self):
|
||||
a,b = [1]
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
l = [1,2,3]
|
||||
print ("l is %r" % l)
|
||||
a,b = l.pop()
|
||||
|
||||
def test_some_error(self):
|
||||
if namenotexi:
|
||||
pass
|
||||
|
||||
def func1(self):
|
||||
assert 41 == 42
|
||||
|
||||
|
||||
# thanks to Matthew Scott for this test
|
||||
def test_dynamic_compile_shows_nicely():
|
||||
src = 'def foo():\n assert 1 == 0\n'
|
||||
name = 'abc-123'
|
||||
module = py.std.imp.new_module(name)
|
||||
code = py.code.compile(src, name, 'exec')
|
||||
py.builtin.exec_(code, module.__dict__)
|
||||
py.std.sys.modules[name] = module
|
||||
module.foo()
|
||||
|
||||
|
||||
class TestSpecialisedExplanations(object):
|
||||
def test_eq_text(self):
|
||||
assert 'spam' == 'eggs'
|
||||
|
@ -191,3 +110,88 @@ def test_attribute_multiple():
|
|||
|
||||
def globf(x):
|
||||
return x+1
|
||||
|
||||
class TestRaises:
|
||||
def test_raises(self):
|
||||
s = 'qwe'
|
||||
raises(TypeError, "int(s)")
|
||||
|
||||
def test_raises_doesnt(self):
|
||||
raises(IOError, "int('3')")
|
||||
|
||||
def test_raise(self):
|
||||
raise ValueError("demo error")
|
||||
|
||||
def test_tupleerror(self):
|
||||
a,b = [1]
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
l = [1,2,3]
|
||||
print ("l is %r" % l)
|
||||
a,b = l.pop()
|
||||
|
||||
def test_some_error(self):
|
||||
if namenotexi:
|
||||
pass
|
||||
|
||||
def func1(self):
|
||||
assert 41 == 42
|
||||
|
||||
|
||||
# thanks to Matthew Scott for this test
|
||||
def test_dynamic_compile_shows_nicely():
|
||||
src = 'def foo():\n assert 1 == 0\n'
|
||||
name = 'abc-123'
|
||||
module = py.std.imp.new_module(name)
|
||||
code = py.code.compile(src, name, 'exec')
|
||||
py.builtin.exec_(code, module.__dict__)
|
||||
py.std.sys.modules[name] = module
|
||||
module.foo()
|
||||
|
||||
|
||||
|
||||
class TestMoreErrors:
|
||||
def test_complex_error(self):
|
||||
def f():
|
||||
return 44
|
||||
def g():
|
||||
return 43
|
||||
somefunc(f(), g())
|
||||
|
||||
def test_z1_unpack_error(self):
|
||||
l = []
|
||||
a,b = l
|
||||
|
||||
def test_z2_type_error(self):
|
||||
l = 3
|
||||
a,b = l
|
||||
|
||||
def test_startswith(self):
|
||||
s = "123"
|
||||
g = "456"
|
||||
assert s.startswith(g)
|
||||
|
||||
def test_startswith_nested(self):
|
||||
def f():
|
||||
return "123"
|
||||
def g():
|
||||
return "456"
|
||||
assert f().startswith(g())
|
||||
|
||||
def test_global_func(self):
|
||||
assert isinstance(globf(42), float)
|
||||
|
||||
def test_instance(self):
|
||||
self.x = 6*7
|
||||
assert self.x != 42
|
||||
|
||||
def test_compare(self):
|
||||
assert globf(10) < 5
|
||||
|
||||
def test_try_finally(self):
|
||||
x = 1
|
||||
try:
|
||||
assert x == 0
|
||||
finally:
|
||||
x = 0
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
Usages and Examples
|
||||
===========================================
|
||||
|
||||
This is a (growing) list of examples. :ref:`Contact <contact>` us if you
|
||||
need more examples or have questions.
|
||||
Here is a (growing) list of examples. :ref:`Contact <contact>` us if you
|
||||
need more examples or have questions. Also take a look at the :ref:`comprehensive documentation <toc>` which contains many example snippets as well.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
reportingdemo.txt
|
||||
simple.txt
|
||||
pythoncollection.txt
|
||||
mysetup.txt
|
||||
|
|
|
@ -18,7 +18,8 @@ change naming conventions
|
|||
-----------------------------------------------------
|
||||
|
||||
You can configure different naming conventions by setting
|
||||
the :confval:`pytest_pycollect` configuration option. Example::
|
||||
the :confval:`python_files`, :confval:`python_classes` and
|
||||
:confval:`python_functions` configuration options. Example::
|
||||
|
||||
# content of setup.cfg
|
||||
# can also be defined in in tox.ini or pytest.ini file
|
||||
|
@ -57,7 +58,7 @@ example if you have unittest2 installed you can type::
|
|||
|
||||
py.test --pyargs unittest2.test.test_skipping -q
|
||||
|
||||
which will run the respective test module. Like with
|
||||
which would run the respective test module. Like with
|
||||
other options, through an ini-file and the :confval:`addopts` option you
|
||||
can make this change more permanently::
|
||||
|
||||
|
|
|
@ -0,0 +1,486 @@
|
|||
|
||||
.. _`tbreportdemo`:
|
||||
|
||||
Demo of Python failure reports with py.test
|
||||
==================================================
|
||||
|
||||
Here is a nice run of several tens of failures
|
||||
and how py.test presents things (unfortunately
|
||||
not showing the nice colors here in the HTML that you
|
||||
get on the terminal - we are working on that)::
|
||||
|
||||
assertion $ py.test failure_demo.py
|
||||
=========================== test session starts ============================
|
||||
platform linux2 -- Python 2.6.5 -- pytest-2.0.0.dev38
|
||||
collecting ...
|
||||
collected 35 items
|
||||
|
||||
failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
|
||||
================================= FAILURES =================================
|
||||
____________________________ test_generative[0] ____________________________
|
||||
|
||||
param1 = 3, param2 = 6
|
||||
|
||||
def test_generative(param1, param2):
|
||||
> assert param1 * 2 < param2
|
||||
E assert (3 * 2) < 6
|
||||
|
||||
failure_demo.py:15: AssertionError
|
||||
_________________________ TestFailing.test_simple __________________________
|
||||
|
||||
self = <failure_demo.TestFailing object at 0x2c9da90>
|
||||
|
||||
def test_simple(self):
|
||||
def f():
|
||||
return 42
|
||||
def g():
|
||||
return 43
|
||||
|
||||
> assert f() == g()
|
||||
E assert 42 == 43
|
||||
E + where 42 = <function f at 0x2c447d0>()
|
||||
E + and 43 = <function g at 0x2c44cf8>()
|
||||
|
||||
failure_demo.py:28: AssertionError
|
||||
____________________ TestFailing.test_simple_multiline _____________________
|
||||
|
||||
self = <failure_demo.TestFailing object at 0x2c9dc90>
|
||||
|
||||
def test_simple_multiline(self):
|
||||
otherfunc_multi(
|
||||
42,
|
||||
> 6*9)
|
||||
|
||||
failure_demo.py:33:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
a = 42, b = 54
|
||||
|
||||
def otherfunc_multi(a,b):
|
||||
assert (a ==
|
||||
> b)
|
||||
E assert 42 == 54
|
||||
|
||||
failure_demo.py:12: AssertionError
|
||||
___________________________ TestFailing.test_not ___________________________
|
||||
|
||||
self = <failure_demo.TestFailing object at 0x2c93f10>
|
||||
|
||||
def test_not(self):
|
||||
def f():
|
||||
return 42
|
||||
> assert not f()
|
||||
E assert not 42
|
||||
E + where 42 = <function f at 0x2ca1050>()
|
||||
|
||||
failure_demo.py:38: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_eq_text _________________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2c9d9d0>
|
||||
|
||||
def test_eq_text(self):
|
||||
> assert 'spam' == 'eggs'
|
||||
E assert 'spam' == 'eggs'
|
||||
E - spam
|
||||
E + eggs
|
||||
|
||||
failure_demo.py:42: AssertionError
|
||||
_____________ TestSpecialisedExplanations.test_eq_similar_text _____________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2a04e90>
|
||||
|
||||
def test_eq_similar_text(self):
|
||||
> assert 'foo 1 bar' == 'foo 2 bar'
|
||||
E assert 'foo 1 bar' == 'foo 2 bar'
|
||||
E - foo 1 bar
|
||||
E ? ^
|
||||
E + foo 2 bar
|
||||
E ? ^
|
||||
|
||||
failure_demo.py:45: AssertionError
|
||||
____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2c9d710>
|
||||
|
||||
def test_eq_multiline_text(self):
|
||||
> assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
||||
E assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
||||
E foo
|
||||
E - spam
|
||||
E + eggs
|
||||
E bar
|
||||
|
||||
failure_demo.py:48: AssertionError
|
||||
______________ TestSpecialisedExplanations.test_eq_long_text _______________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2c9db10>
|
||||
|
||||
def test_eq_long_text(self):
|
||||
a = '1'*100 + 'a' + '2'*100
|
||||
b = '1'*100 + 'b' + '2'*100
|
||||
> assert a == b
|
||||
E assert '111111111111...2222222222222' == '111111111111...2222222222222'
|
||||
E Skipping 90 identical leading characters in diff
|
||||
E Skipping 91 identical trailing characters in diff
|
||||
E - 1111111111a222222222
|
||||
E ? ^
|
||||
E + 1111111111b222222222
|
||||
E ? ^
|
||||
|
||||
failure_demo.py:53: AssertionError
|
||||
_________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2caf950>
|
||||
|
||||
def test_eq_long_text_multiline(self):
|
||||
a = '1\n'*100 + 'a' + '2\n'*100
|
||||
b = '1\n'*100 + 'b' + '2\n'*100
|
||||
> assert a == b
|
||||
E assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n...n2\n2\n2\n2\n'
|
||||
E Skipping 190 identical leading characters in diff
|
||||
E Skipping 191 identical trailing characters in diff
|
||||
E 1
|
||||
E 1
|
||||
E 1
|
||||
E 1
|
||||
E 1
|
||||
E - a2
|
||||
E + b2
|
||||
E 2
|
||||
E 2
|
||||
E 2
|
||||
E 2
|
||||
|
||||
failure_demo.py:58: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_eq_list _________________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2caf590>
|
||||
|
||||
def test_eq_list(self):
|
||||
> assert [0, 1, 2] == [0, 1, 3]
|
||||
E assert [0, 1, 2] == [0, 1, 3]
|
||||
E At index 2 diff: 2 != 3
|
||||
|
||||
failure_demo.py:61: AssertionError
|
||||
______________ TestSpecialisedExplanations.test_eq_list_long _______________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2c9e310>
|
||||
|
||||
def test_eq_list_long(self):
|
||||
a = [0]*100 + [1] + [3]*100
|
||||
b = [0]*100 + [2] + [3]*100
|
||||
> assert a == b
|
||||
E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
|
||||
E At index 100 diff: 1 != 2
|
||||
|
||||
failure_demo.py:66: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_eq_dict _________________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2c9dc50>
|
||||
|
||||
def test_eq_dict(self):
|
||||
> assert {'a': 0, 'b': 1} == {'a': 0, 'b': 2}
|
||||
E assert {'a': 0, 'b': 1} == {'a': 0, 'b': 2}
|
||||
E - {'a': 0, 'b': 1}
|
||||
E ? ^
|
||||
E + {'a': 0, 'b': 2}
|
||||
E ? ^
|
||||
|
||||
failure_demo.py:69: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_eq_set __________________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2cafc10>
|
||||
|
||||
def test_eq_set(self):
|
||||
> assert set([0, 10, 11, 12]) == set([0, 20, 21])
|
||||
E assert set([0, 10, 11, 12]) == set([0, 20, 21])
|
||||
E Extra items in the left set:
|
||||
E 10
|
||||
E 11
|
||||
E 12
|
||||
E Extra items in the right set:
|
||||
E 20
|
||||
E 21
|
||||
|
||||
failure_demo.py:72: AssertionError
|
||||
_____________ TestSpecialisedExplanations.test_eq_longer_list ______________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2cba890>
|
||||
|
||||
def test_eq_longer_list(self):
|
||||
> assert [1,2] == [1,2,3]
|
||||
E assert [1, 2] == [1, 2, 3]
|
||||
E Right contains more items, first extra item: 3
|
||||
|
||||
failure_demo.py:75: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_in_list _________________
|
||||
|
||||
self = <failure_demo.TestSpecialisedExplanations object at 0x2cba6d0>
|
||||
|
||||
def test_in_list(self):
|
||||
> assert 1 in [0, 2, 3, 4, 5]
|
||||
E assert 1 in [0, 2, 3, 4, 5]
|
||||
|
||||
failure_demo.py:78: AssertionError
|
||||
______________________________ test_attribute ______________________________
|
||||
|
||||
def test_attribute():
|
||||
class Foo(object):
|
||||
b = 1
|
||||
i = Foo()
|
||||
> assert i.b == 2
|
||||
E assert 1 == 2
|
||||
E + where 1 = <failure_demo.Foo object at 0x2c9d750>.b
|
||||
|
||||
failure_demo.py:85: AssertionError
|
||||
_________________________ test_attribute_instance __________________________
|
||||
|
||||
def test_attribute_instance():
|
||||
class Foo(object):
|
||||
b = 1
|
||||
> assert Foo().b == 2
|
||||
E assert 1 == 2
|
||||
E + where 1 = <failure_demo.Foo object at 0x2cafdd0>.b
|
||||
E + where <failure_demo.Foo object at 0x2cafdd0> = <class 'failure_demo.Foo'>()
|
||||
|
||||
failure_demo.py:91: AssertionError
|
||||
__________________________ test_attribute_failure __________________________
|
||||
|
||||
def test_attribute_failure():
|
||||
class Foo(object):
|
||||
def _get_b(self):
|
||||
raise Exception('Failed to get attrib')
|
||||
b = property(_get_b)
|
||||
i = Foo()
|
||||
> assert i.b == 2
|
||||
|
||||
failure_demo.py:100:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
self = <failure_demo.Foo object at 0x2cba790>
|
||||
|
||||
def _get_b(self):
|
||||
> raise Exception('Failed to get attrib')
|
||||
E Exception: Failed to get attrib
|
||||
|
||||
failure_demo.py:97: Exception
|
||||
_________________________ test_attribute_multiple __________________________
|
||||
|
||||
def test_attribute_multiple():
|
||||
class Foo(object):
|
||||
b = 1
|
||||
class Bar(object):
|
||||
b = 2
|
||||
> assert Foo().b == Bar().b
|
||||
E assert 1 == 2
|
||||
E + where 1 = <failure_demo.Foo object at 0x2cba210>.b
|
||||
E + where <failure_demo.Foo object at 0x2cba210> = <class 'failure_demo.Foo'>()
|
||||
E + and 2 = <failure_demo.Bar object at 0x2cba850>.b
|
||||
E + where <failure_demo.Bar object at 0x2cba850> = <class 'failure_demo.Bar'>()
|
||||
|
||||
failure_demo.py:108: AssertionError
|
||||
__________________________ TestRaises.test_raises __________________________
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cc2560>
|
||||
|
||||
def test_raises(self):
|
||||
s = 'qwe'
|
||||
> raises(TypeError, "int(s)")
|
||||
|
||||
failure_demo.py:117:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
> int(s)
|
||||
E ValueError: invalid literal for int() with base 10: 'qwe'
|
||||
|
||||
<0-codegen /home/hpk/p/pytest/_pytest/python.py:819>:1: ValueError
|
||||
______________________ TestRaises.test_raises_doesnt _______________________
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cb6bd8>
|
||||
|
||||
def test_raises_doesnt(self):
|
||||
> raises(IOError, "int('3')")
|
||||
E Failed: DID NOT RAISE
|
||||
|
||||
failure_demo.py:120: Failed
|
||||
__________________________ TestRaises.test_raise ___________________________
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cc4830>
|
||||
|
||||
def test_raise(self):
|
||||
> raise ValueError("demo error")
|
||||
E ValueError: demo error
|
||||
|
||||
failure_demo.py:123: ValueError
|
||||
________________________ TestRaises.test_tupleerror ________________________
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cc5560>
|
||||
|
||||
def test_tupleerror(self):
|
||||
> a,b = [1]
|
||||
E ValueError: need more than 1 value to unpack
|
||||
|
||||
failure_demo.py:126: ValueError
|
||||
______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cc6248>
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
l = [1,2,3]
|
||||
print ("l is %r" % l)
|
||||
> a,b = l.pop()
|
||||
E TypeError: 'int' object is not iterable
|
||||
|
||||
failure_demo.py:131: TypeError
|
||||
----------------------------- Captured stdout ------------------------------
|
||||
l is [1, 2, 3]
|
||||
________________________ TestRaises.test_some_error ________________________
|
||||
|
||||
self = <failure_demo.TestRaises instance at 0x2cc6f38>
|
||||
|
||||
def test_some_error(self):
|
||||
> if namenotexi:
|
||||
E NameError: global name 'namenotexi' is not defined
|
||||
|
||||
failure_demo.py:134: NameError
|
||||
____________________ test_dynamic_compile_shows_nicely _____________________
|
||||
|
||||
def test_dynamic_compile_shows_nicely():
|
||||
src = 'def foo():\n assert 1 == 0\n'
|
||||
name = 'abc-123'
|
||||
module = py.std.imp.new_module(name)
|
||||
code = py.code.compile(src, name, 'exec')
|
||||
py.builtin.exec_(code, module.__dict__)
|
||||
py.std.sys.modules[name] = module
|
||||
> module.foo()
|
||||
|
||||
failure_demo.py:149:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
def foo():
|
||||
> assert 1 == 0
|
||||
E assert 1 == 0
|
||||
|
||||
<2-codegen 'abc-123' /home/hpk/p/pytest/doc/example/assertion/failure_demo.py:146>:2: AssertionError
|
||||
____________________ TestMoreErrors.test_complex_error _____________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2cc4050>
|
||||
|
||||
def test_complex_error(self):
|
||||
def f():
|
||||
return 44
|
||||
def g():
|
||||
return 43
|
||||
> somefunc(f(), g())
|
||||
|
||||
failure_demo.py:159:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
x = 44, y = 43
|
||||
|
||||
def somefunc(x,y):
|
||||
> otherfunc(x,y)
|
||||
|
||||
failure_demo.py:8:
|
||||
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||
|
||||
a = 44, b = 43
|
||||
|
||||
def otherfunc(a,b):
|
||||
> assert a==b
|
||||
E assert 44 == 43
|
||||
|
||||
failure_demo.py:5: AssertionError
|
||||
___________________ TestMoreErrors.test_z1_unpack_error ____________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2cc7ab8>
|
||||
|
||||
def test_z1_unpack_error(self):
|
||||
l = []
|
||||
> a,b = l
|
||||
E ValueError: need more than 0 values to unpack
|
||||
|
||||
failure_demo.py:163: ValueError
|
||||
____________________ TestMoreErrors.test_z2_type_error _____________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2ccb8c0>
|
||||
|
||||
def test_z2_type_error(self):
|
||||
l = 3
|
||||
> a,b = l
|
||||
E TypeError: 'int' object is not iterable
|
||||
|
||||
failure_demo.py:167: TypeError
|
||||
______________________ TestMoreErrors.test_startswith ______________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2ccd5f0>
|
||||
|
||||
def test_startswith(self):
|
||||
s = "123"
|
||||
g = "456"
|
||||
> assert s.startswith(g)
|
||||
E assert <built-in method startswith of str object at 0x2c321b0>('456')
|
||||
E + where <built-in method startswith of str object at 0x2c321b0> = '123'.startswith
|
||||
|
||||
failure_demo.py:172: AssertionError
|
||||
__________________ TestMoreErrors.test_startswith_nested ___________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2ccbc20>
|
||||
|
||||
def test_startswith_nested(self):
|
||||
def f():
|
||||
return "123"
|
||||
def g():
|
||||
return "456"
|
||||
> assert f().startswith(g())
|
||||
E assert <built-in method startswith of str object at 0x2c321b0>('456')
|
||||
E + where <built-in method startswith of str object at 0x2c321b0> = '123'.startswith
|
||||
E + where '123' = <function f at 0x2c2d140>()
|
||||
E + and '456' = <function g at 0x2cb00c8>()
|
||||
|
||||
failure_demo.py:179: AssertionError
|
||||
_____________________ TestMoreErrors.test_global_func ______________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2cb69e0>
|
||||
|
||||
def test_global_func(self):
|
||||
> assert isinstance(globf(42), float)
|
||||
E assert isinstance(43, float)
|
||||
E + where 43 = globf(42)
|
||||
|
||||
failure_demo.py:182: AssertionError
|
||||
_______________________ TestMoreErrors.test_instance _______________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2cc6440>
|
||||
|
||||
def test_instance(self):
|
||||
self.x = 6*7
|
||||
> assert self.x != 42
|
||||
E assert 42 != 42
|
||||
E + where 42 = 42
|
||||
E + where 42 = <failure_demo.TestMoreErrors instance at 0x2cc6440>.x
|
||||
|
||||
failure_demo.py:186: AssertionError
|
||||
_______________________ TestMoreErrors.test_compare ________________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2dcc200>
|
||||
|
||||
def test_compare(self):
|
||||
> assert globf(10) < 5
|
||||
E assert 11 < 5
|
||||
E + where 11 = globf(10)
|
||||
|
||||
failure_demo.py:189: AssertionError
|
||||
_____________________ TestMoreErrors.test_try_finally ______________________
|
||||
|
||||
self = <failure_demo.TestMoreErrors instance at 0x2dce0e0>
|
||||
|
||||
def test_try_finally(self):
|
||||
x = 1
|
||||
try:
|
||||
> assert x == 0
|
||||
E assert 1 == 0
|
||||
|
||||
failure_demo.py:194: AssertionError
|
||||
======================== 35 failed in 0.19 seconds =========================
|
|
@ -1,26 +1,9 @@
|
|||
|
||||
.. highlightlang:: python
|
||||
|
||||
simple hook using patterns
|
||||
basic patterns and examples
|
||||
==========================================================
|
||||
|
||||
adding custom options
|
||||
----------------------
|
||||
|
||||
py.test supports adding of standard optparse_ Options.
|
||||
A plugin may implement the ``addoption`` hook for registering
|
||||
custom options::
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption("-M", "--myopt", action="store",
|
||||
help="specify string to set myopt")
|
||||
|
||||
def pytest_configure(config):
|
||||
if config.option.myopt:
|
||||
# do action based on option value
|
||||
|
||||
.. _optparse: http://docs.python.org/library/optparse.html
|
||||
|
||||
pass different values to a test function, depending on command line options
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
|
@ -37,7 +20,7 @@ Here is a basic pattern how to achieve this::
|
|||
|
||||
|
||||
For this to work we need to add a command line option and
|
||||
provide the ``cmdopt`` through a function argument factory::
|
||||
provide the ``cmdopt`` through a :ref:`function argument <funcarg>` factory::
|
||||
|
||||
# content of conftest.py
|
||||
def pytest_addoption(parser):
|
||||
|
|
10
doc/faq.txt
10
doc/faq.txt
|
@ -6,7 +6,7 @@ Some Issues and Questions
|
|||
If you don't find an answer here, checkout the :ref:`contact channels`
|
||||
to get help.
|
||||
|
||||
On naming, nosetests, licensing and magic XXX
|
||||
On naming, nosetests, licensing and magic
|
||||
------------------------------------------------
|
||||
|
||||
Why a ``py.test`` instead of a ``pytest`` command?
|
||||
|
@ -21,14 +21,16 @@ but then again many people have gotten used to the old name and there
|
|||
is another tool named "pytest" so we just decided to stick with
|
||||
``py.test``.
|
||||
|
||||
What's py.test's relation to ``nosetests``?
|
||||
What's the relation to nose and unittest?
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
py.test and nose_ share basic philosophy when it comes
|
||||
to running Python tests. In fact, you can run many tests
|
||||
written for unittest or nose with py.test. nose_ was originally created
|
||||
written nose with py.test. nose_ was originally created
|
||||
as a clone of ``py.test`` when py.test was in the ``0.8`` release
|
||||
cycle.
|
||||
cycle. As of version 2.0 support for running unittest test
|
||||
suites is majorly improved and you should be able to run
|
||||
many Django and Twisted test suites.
|
||||
|
||||
.. _features: test/features.html
|
||||
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
py.test Features
|
||||
==================
|
||||
|
||||
mature no-boilerplate testing with Python
|
||||
------------------------------------------------
|
||||
|
||||
- automatic, customizable :ref:`Python test discovery`
|
||||
- simple test functions and freely groupable tests
|
||||
- simple ``assert`` statements for assertions
|
||||
- powerful parametrization of test functions
|
||||
- very helpful traceback and failing assertion reporting
|
||||
- use ``print`` or ``pdb`` debugging on failures
|
||||
- enables fully :pep:`8` compliant coding style
|
||||
- powerful :ref:`usage` possibilities, well sorted command line options
|
||||
- used in many projects, ranging from 10 to 10K tests
|
||||
- tested on Unix and Windows from Python 2.4 up to Python 3.1 and 3.2
|
||||
- keyword/testname based selection of tests
|
||||
|
||||
supports common testing practises and methods
|
||||
-----------------------------------------------------------
|
||||
|
||||
- can integrate ``nose``, ``unittest.py`` and ``doctest.py`` style
|
||||
tests, including running testcases made for Django and trial
|
||||
- supports extended `xUnit style setup`_
|
||||
- supports domain-specific :ref:`non-python tests`
|
||||
- supports generating testing coverage reports
|
||||
- `Javasript unit- and functional testing`_
|
||||
|
||||
.. _`Javasript unit- and functional testing`: http://pypi.python.org/pypi/oejskit
|
||||
|
||||
distributing tests to local/remote subprocesses
|
||||
--------------------------------------------------------
|
||||
|
||||
- can distribute tests to multiple CPUs
|
||||
- can distribute tests to remote ssh or socket connected machines
|
||||
- can run tests in subprocess, re-run failing ones on file-change
|
||||
|
||||
extensive plugin and customization system
|
||||
------------------------------------------------------
|
||||
|
||||
.. _`easy`: http://bruynooghe.blogspot.com/2009/12/skipping-slow-test-by-default-in-pytest.html
|
||||
|
||||
- all collection, reporting, running aspects are delegated to hook functions
|
||||
- hook functions are implemented per-directory, per-project or through PyPI released plugins
|
||||
- it is `easy`_ to add command line options or
|
||||
do other kind of add-ons and customizations.
|
||||
|
||||
integrates well with CI systems
|
||||
----------------------------------------
|
||||
|
||||
- produces compatible JunitXML output for Hudson or other CI servers
|
||||
- produces "resultlog" text files for easy parsing
|
||||
- integrates well with tox_
|
||||
|
||||
.. _`tox`: http://codespeak.net/tox
|
||||
|
||||
skip or expect-to-fail a test
|
||||
-------------------------------------------
|
||||
|
||||
- skip tests if there are platform or dependency mismatches
|
||||
- xfail a test (on certain platforms)indicating an implementation problem
|
||||
- you can use skip and xfail imperatively or as a decorating marker
|
||||
|
||||
.. include:: links.inc
|
|
@ -8,14 +8,25 @@ creating and managing test function arguments
|
|||
.. _`funcargs`:
|
||||
.. _`funcarg mechanism`:
|
||||
|
||||
Test function arguments and factories
|
||||
Dependency injection through function arguments
|
||||
=================================================
|
||||
|
||||
A *funcarg* is the short name for "test function argument". Like
|
||||
any other Python function a test function can receive one or multiple
|
||||
arguments. When ``py.test`` prepares running a test function
|
||||
it looks at the neccessary function arguments, locates and calls
|
||||
factories which then provide the values to be passed to the function.
|
||||
py.test allows to inject values into test functions through the *funcarg
|
||||
mechanism*: For each argument name in a test function signature a factory is
|
||||
looked up and called to create the value. The factory can live in the
|
||||
same test class, test module, in a per-directory ``confest.py`` file or
|
||||
in an external plugin. It has full access to the requesting test
|
||||
function, can register finalizers and invoke lifecycle-caching
|
||||
helpers. As can be expected from a systematic dependency
|
||||
injection mechanism, this allows full de-coupling of resource and
|
||||
fixture setup from test code, enabling more maintainable and
|
||||
easy-to-modify test suites.
|
||||
|
||||
A test function may be invoked multiple times in which case we
|
||||
speak of :ref:`parametrized testing <parametrizing-tests>`. This can be
|
||||
very useful if you want to test e.g. against different database backends
|
||||
or with multiple numerical arguments sets and want to reuse the same set
|
||||
of test functions.
|
||||
|
||||
Basic funcarg example
|
||||
-----------------------
|
||||
|
@ -53,17 +64,19 @@ Running the test looks like this::
|
|||
|
||||
This means that the test function was called with a ``myfuncarg`` value
|
||||
of ``42`` and the assert fails accordingly. Here is how py.test
|
||||
calls the test function:
|
||||
comes to call the test function this way:
|
||||
|
||||
1. py.test discovers the ``test_function`` because of the ``test_`` prefix.
|
||||
The test function needs a function argument named ``myfuncarg``.
|
||||
A matching factory function is discovered by looking for the
|
||||
name ``pytest_funcarg__myfuncarg``.
|
||||
1. py.test :ref:`finds <test discovery>` the ``test_function`` because
|
||||
of the ``test_`` prefix. The test function needs a function argument
|
||||
named ``myfuncarg``. A matching factory function is discovered by
|
||||
looking for the name ``pytest_funcarg__myfuncarg``.
|
||||
|
||||
2. ``pytest_funcarg__myfuncarg(request)`` is called and
|
||||
returns the value for ``myfuncarg``.
|
||||
|
||||
3. ``test_function(42)`` call is executed.
|
||||
3. the test function can now be called: ``test_function(42)``
|
||||
and results in the above exception because of the assertion
|
||||
mismatch.
|
||||
|
||||
Note that if you misspell a function argument or want
|
||||
to use one that isn't available, you'll see an error
|
||||
|
@ -108,6 +121,7 @@ factory and provides access to test configuration and context:
|
|||
|
||||
.. _`test generators`:
|
||||
.. _`parametrizing-tests`:
|
||||
.. _`parametrized test functions`:
|
||||
|
||||
Parametrizing multiple calls to a test function
|
||||
===========================================================
|
||||
|
|
|
@ -3,6 +3,8 @@ Installation and Getting Started
|
|||
|
||||
**Compatibility**: Python 2.4-3.2, Jython, PyPy on Unix/Posix and Windows
|
||||
|
||||
.. _`getstarted`:
|
||||
|
||||
Installation
|
||||
----------------------------------------
|
||||
|
||||
|
@ -18,6 +20,8 @@ To check your installation has installed the correct version::
|
|||
|
||||
If you get an error checkout :ref:`installation issues`.
|
||||
|
||||
.. _`simpletest`:
|
||||
|
||||
Our first test run
|
||||
----------------------------------------------------------
|
||||
|
||||
|
@ -55,16 +59,16 @@ py.test found the ``test_answer`` function by following :ref:`standard test disc
|
|||
.. note::
|
||||
|
||||
You can simply use the ``assert`` statement for coding expectations because
|
||||
intermediate values will be presented to you. This is much easier than
|
||||
learning all the `the JUnit legacy methods`_ which are even inconsistent
|
||||
with Python's own coding guidelines (but consistent with
|
||||
Java-style naming).
|
||||
intermediate values will be presented to you. This is arguably easier than
|
||||
learning all the `the JUnit legacy methods`_.
|
||||
|
||||
There is only one seldomly hit caveat to using asserts: if your
|
||||
assertion expression fails and has side effects then re-evaluating
|
||||
it for presenting intermediate values can go wrong. It's easy to fix:
|
||||
compute the value ahead of the assert and then do the
|
||||
assertion or use the assert "message" syntax::
|
||||
However, there remains one caveat to using simple asserts: your
|
||||
assertion expression should better be side-effect free. Because
|
||||
after an assertion failed py.test will re-evaluate the expression
|
||||
in order to present intermediate values. You will get a nice warning
|
||||
and you can easily fix it: compute the value ahead of the assert and
|
||||
then do the assertion. Or maybe just use the assert "explicit message"
|
||||
syntax::
|
||||
|
||||
assert expr, "message" # show "message" if expr is not True
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
.. highlightlang:: python
|
||||
.. _`good practises`:
|
||||
.. _`goodpractises`:
|
||||
|
||||
Good Integration Practises
|
||||
=================================================
|
||||
|
@ -21,6 +21,78 @@ server Hudson_.
|
|||
.. _`buildout`: http://www.buildout.org/
|
||||
.. _pip: http://pypi.python.org/pypi/pip
|
||||
|
||||
Use tox and Continous Integration servers
|
||||
-------------------------------------------------
|
||||
|
||||
If you are (often) releasing code to the public you
|
||||
may want to look into `tox`_, the virtualenv test automation
|
||||
tool and its `pytest support <http://codespeak.net/tox/example/pytest.html>`_.
|
||||
The basic idea is to generate a JUnitXML file through the ``--junitxml=PATH`` option and have a continous integration server like Hudson_ pick it up.
|
||||
|
||||
.. _standalone:
|
||||
.. _`genscript method`:
|
||||
|
||||
Create a py.test standalone Script
|
||||
-------------------------------------------
|
||||
|
||||
If you are a maintainer or application developer and want others
|
||||
to easily run tests you can generate a completely standalone "py.test"
|
||||
script::
|
||||
|
||||
py.test --genscript=runtests.py
|
||||
|
||||
generates a ``runtests.py`` script which is a fully functional basic
|
||||
``py.test`` script, running unchanged under Python2 and Python3.
|
||||
You can tell people to download the script and then e.g. run it like this::
|
||||
|
||||
python runtests.py
|
||||
|
||||
|
||||
.. _`Distribute for installation`: http://pypi.python.org/pypi/distribute#installation-instructions
|
||||
.. _`distribute installation`: http://pypi.python.org/pypi/distribute
|
||||
|
||||
|
||||
Integrating with distutils / ``python setup.py test``
|
||||
--------------------------------------------------------
|
||||
|
||||
You can easily integrate test runs into your distutils or
|
||||
setuptools based project. Use the `genscript method`_
|
||||
to generate a standalone py.test script::
|
||||
|
||||
py.test --genscript=runtests.py
|
||||
|
||||
and make this script part of your distribution and then add
|
||||
this to your ``setup.py`` file::
|
||||
|
||||
from distutils.core import setup, Command
|
||||
# you can also import from setuptools
|
||||
|
||||
class PyTest(Command):
|
||||
user_options = []
|
||||
def initialize_options(self):
|
||||
pass
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
import sys,subprocess
|
||||
errno = subprocess.call([sys.executable, 'runtest.py'])
|
||||
raise SystemExit(errno)
|
||||
setup(
|
||||
#...,
|
||||
cmdclass = {'test': PyTest},
|
||||
#...,
|
||||
)
|
||||
|
||||
If you now type::
|
||||
|
||||
python setup.py test
|
||||
|
||||
this will execute your tests using ``runtest.py``. As this is a
|
||||
standalone version of ``py.test`` no prior installation whatsoever is
|
||||
required for calling the test command. You can also pass additional
|
||||
arguments to the subprocess-calls like your test directory or other
|
||||
options.
|
||||
|
||||
.. _`test discovery`:
|
||||
.. _`Python test discovery`:
|
||||
|
||||
|
@ -93,70 +165,5 @@ You can always run your tests by pointing to it::
|
|||
you must follow the convention of having directory and file
|
||||
names map to the import names.
|
||||
|
||||
.. _standalone:
|
||||
.. _`genscript method`:
|
||||
|
||||
Generating a py.test standalone Script
|
||||
-------------------------------------------
|
||||
|
||||
If you are a maintainer or application developer and want others
|
||||
to easily run tests you can generate a completely standalone "py.test"
|
||||
script::
|
||||
|
||||
py.test --genscript=runtests.py
|
||||
|
||||
generates a ``runtests.py`` script which is a fully functional basic
|
||||
``py.test`` script, running unchanged under Python2 and Python3.
|
||||
You can tell people to download and then e.g. run it like this to
|
||||
produce a Paste URL::
|
||||
|
||||
python runtests.py --pastebin=all
|
||||
|
||||
and ask them to send you the resulting URL.
|
||||
|
||||
.. _`Distribute for installation`: http://pypi.python.org/pypi/distribute#installation-instructions
|
||||
.. _`distribute installation`: http://pypi.python.org/pypi/distribute
|
||||
|
||||
|
||||
Integrating with distutils / ``python setup.py test``
|
||||
--------------------------------------------------------
|
||||
|
||||
You can easily integrate test runs into your distutils or
|
||||
setuptools based project. Use the `genscript method`_
|
||||
to generate a standalone py.test script::
|
||||
|
||||
py.test --genscript=runtests.py
|
||||
|
||||
and make this script part of your distribution and then add
|
||||
this to your ``setup.py`` file::
|
||||
|
||||
from distutils.core import setup, Command
|
||||
# you can also import from setuptools
|
||||
|
||||
class PyTest(Command):
|
||||
user_options = []
|
||||
def initialize_options(self):
|
||||
pass
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
import sys,subprocess
|
||||
errno = subprocess.call([sys.executable, 'runtest.py'])
|
||||
raise SystemExit(errno)
|
||||
setup(
|
||||
#...,
|
||||
cmdclass = {'test': PyTest},
|
||||
#...,
|
||||
)
|
||||
|
||||
If you now type::
|
||||
|
||||
python setup.py test
|
||||
|
||||
this will execute your tests using ``runtest.py``. As this is a
|
||||
standalone version of ``py.test`` no prior installation whatsoever is
|
||||
required for calling the test command. You can also pass additional
|
||||
arguments to the subprocess-calls like your test directory or other
|
||||
options.
|
||||
|
||||
.. include:: links.inc
|
||||
|
|
|
@ -1,35 +1,59 @@
|
|||
py.test: no-boilerplate testing with Python
|
||||
==============================================
|
||||
|
||||
.. todolist::
|
||||
|
||||
.. note::
|
||||
version 2.0 introduces ``pytest`` as the main Python import name
|
||||
in examples but you can continue to use ``import py`` and
|
||||
``py.test.XYZ`` to access :ref:`pytest helpers` in your test code.
|
||||
Welcome to ``py.test``!
|
||||
=============================================
|
||||
|
||||
Welcome to ``py.test`` documentation:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
- **a mature fully featured testing tool**
|
||||
|
||||
overview
|
||||
apiref
|
||||
plugins
|
||||
example/index
|
||||
talks
|
||||
develop
|
||||
announce/index
|
||||
- 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/>`_
|
||||
- used in :ref:`many projects <projects>`, ranging from 10 to 10000 tests
|
||||
- has :ref:`comprehensive documentation <toc>`
|
||||
- comes with :ref:`tested examples <examples>`
|
||||
- supports :ref:`good integration practises <goodpractises>`
|
||||
|
||||
- **provides no-boilerplate testing**
|
||||
|
||||
- makes it :ref:`easy to get started <getstarted>`, refined :ref:`usage options <usage>`
|
||||
- :ref:`assert with the assert statement`
|
||||
- helpful :ref:`traceback and failing assertion reporting <tbreportdemo>`
|
||||
- allows `print debugging <printdebugging>`_ and `generic output capturing <captures>`_
|
||||
- supports :pep:`8` compliant coding style in tests
|
||||
|
||||
- **supports functional testing and complex test setups**
|
||||
|
||||
- advanced :ref:`skip and xfail`
|
||||
- generic :ref:`marking and test selection <mark>`
|
||||
- can :ref:`distribute tests to multiple CPUs <xdistcpu>` through :ref:`xdist plugin <xdist>`
|
||||
- can :ref:`continously re-run failing tests <looponfailing>`
|
||||
- many :ref:`builtin helpers <pytest helpers>`
|
||||
- flexible :ref:`Python test discovery`
|
||||
- unique :ref:`dependency injection through funcargs <funcargs>`
|
||||
- :ref:`parametrized test functions <parametrized test functions>`
|
||||
|
||||
- **integrates many common testing methods**
|
||||
|
||||
- can integrate ``nose``, ``unittest.py`` and ``doctest.py`` style
|
||||
tests, including running testcases made for Django and trial
|
||||
- supports extended :ref:`xUnit style setup <xunitsetup>`
|
||||
- supports domain-specific :ref:`non-python tests`
|
||||
- supports generating testing coverage reports
|
||||
- `Javasript unit- and functional testing`_
|
||||
|
||||
- **extensive plugin and customization system**
|
||||
|
||||
- all collection, reporting, running aspects are delegated to hook functions
|
||||
- customizations can be per-directory, per-project or per PyPI released plugins
|
||||
- it is easy to add command line options or do other kind of add-ons and customizations.
|
||||
|
||||
.. _`Javasript unit- and functional testing`: http://pypi.python.org/pypi/oejskit
|
||||
|
||||
.. _`easy`: http://bruynooghe.blogspot.com/2009/12/skipping-slow-test-by-default-in-pytest.html
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
changelog.txt
|
||||
example/attic
|
||||
contact.txt
|
||||
contents.txt
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
.. _naming20:
|
||||
|
||||
New pytest names in 2.0 (flat is better than nested)
|
||||
----------------------------------------------------
|
||||
|
||||
If you used older version of the ``py`` distribution (which
|
||||
included the py.test command line tool and Python name space)
|
||||
you accessed helpers and possibly collection classes through
|
||||
the ``py.test`` Python namespaces. The new ``pytest``
|
||||
Python module flaty provides the same objects, following
|
||||
these renaming rules::
|
||||
|
||||
py.test.XYZ -> pytest.XYZ
|
||||
py.test.collect.XYZ -> pytest.XYZ
|
||||
py.test.cmdline.main -> pytest.main
|
||||
|
||||
The old ``py.test.*`` ways to access functionality remain
|
||||
valid but you are encouraged to do global renames according
|
||||
to the above rules in your test code.
|
|
@ -1,13 +1,13 @@
|
|||
==================================================
|
||||
Overview and Introduction
|
||||
Getting started basics
|
||||
==================================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
features.txt
|
||||
getting-started.txt
|
||||
usage.txt
|
||||
goodpractises.txt
|
||||
projects.txt
|
||||
faq.txt
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
.. _projects:
|
||||
|
||||
Project Examples
|
||||
==========================
|
||||
|
||||
Here are some examples of projects using py.test:
|
||||
|
||||
* `PyPy <http://pypy.org>`_, Python with a JIT compiler, running over `16000 tests <http://test.pypy.org>`_
|
||||
* the `MoinMoin <http://moinmo.in>`_ Wiki Engine
|
||||
* `tox <http://codespeak.net/tox>`_, virtualenv/Hudson integration tool
|
||||
* `PIDA <http://pida.co.uk>`_ framework for integrated development
|
||||
* `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB
|
||||
* `six <http://pypi.python.org/pypi/six/>`_ Python 2 and 3 compatibility utilities
|
||||
* `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion
|
||||
* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
|
||||
* `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem
|
||||
* `Circuits <http://pypi.python.org/pypi/circuits/1.2.1>`_ lightweight Event Driven Framework
|
||||
* `pygtk-helpers <http://bitbucket.org/aafshar/pygtkhelpers-main/>`_ easy interaction with PyGTK
|
||||
* `QuantumCore <http://quantumcore.org/>`_ statusmessage and repoze openid plugin
|
||||
* `pydataportability <http://pydataportability.net/>`_ libraries for managing the open web
|
||||
* `XIST <http://www.livinglogic.de/Python/xist/>`_ extensible HTML/XML generator
|
||||
* `tiddlyweb <http://pypi.python.org/pypi/tiddlyweb>`_ optionally headless, extensible RESTful datastore
|
||||
* `Paludis <http://paludis-tools.lunaryorn.de/>`_ tools for Gentoo Paludis package manager
|
||||
* `Gerald <http://halfcooked.com/code/gerald/>`_ schema comparison tool
|
||||
* `abjad <http://code.google.com/p/abjad/>`_ Python API for Formalized Score control
|
||||
* `bu <http://packages.python.org/bu/>`_ a microscopic build system
|
||||
* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
|
||||
* `kss plugin timer <http://pypi.python.org/pypi/kss.plugin.timer>`_
|
||||
* many more ... (please send notes via the :ref:`contact`)
|
||||
|
||||
Some examples of organisations using py.test
|
||||
----------------------------------------------
|
||||
|
||||
* `Square Kilometre Array <http://ska.ac.za/>`_
|
||||
* `Tandberg <http://www.tandberg.com/>`_
|
||||
* `Stups department of Heinrich Heine University <http://www.stups.uni-duesseldorf.de/projects.php>`_
|
||||
* `Open End <http://openend.se>`_
|
||||
* `Laboraratory of Bioinformatics <http://genesilico.pl/>`_
|
||||
* `merlinux <http://merlinux.eu>`_
|
||||
* many more ... (please send a note via the :ref:`contact`)
|
|
@ -1,13 +1,15 @@
|
|||
|
||||
.. _`skip and xfail`:
|
||||
|
||||
skip and xfail mechanisms
|
||||
=====================================================================
|
||||
|
||||
You can skip or "xfail" test functions, either by marking functions
|
||||
through a decorator or by calling the ``pytest.skip|xfail`` helpers.
|
||||
A *skip* means that you expect your test to pass unless a certain configuration or condition (e.g. wrong Python interpreter, missing dependency) prevents it to run. And *xfail* means that you expect your test to fail because there is an
|
||||
implementation problem. Counting and listing *xfailing* tests separately
|
||||
helps to maintain a list of implementation problems and you can provide
|
||||
info such as a bug number or a URL to provide a human readable problem context.
|
||||
implementation problem. py.test counts and lists *xfailing* tests separately
|
||||
and you can provide info such as a bug number or a URL to provide a
|
||||
human readable problem context.
|
||||
|
||||
Usually detailed information about skipped/xfailed tests is not shown
|
||||
to avoid cluttering the output. You can use the ``-r`` option to
|
||||
|
@ -16,6 +18,8 @@ test progress::
|
|||
|
||||
py.test -rxs # show extra info on skips and xfail tests
|
||||
|
||||
(See :ref:`how to change command line options defaults`)
|
||||
|
||||
.. _skipif:
|
||||
|
||||
Skipping a single function
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
.. _`xdist`:
|
||||
|
||||
xdist: pytest distributed testing plugin
|
||||
===============================================================
|
||||
|
||||
|
@ -38,9 +41,12 @@ a checkout of the `pytest-xdist repository`_ ::
|
|||
|
||||
python setup.py develop
|
||||
|
||||
|
||||
Usage examples
|
||||
---------------------
|
||||
|
||||
.. _`xdistcpu`:
|
||||
|
||||
Speed up test runs by sending tests to multiple CPUs
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
@ -69,6 +75,24 @@ If you prefix the --tx option value like this::
|
|||
then three subprocesses would be created and tests
|
||||
will be load-balanced across these three processes.
|
||||
|
||||
.. _looponfailing:
|
||||
|
||||
|
||||
Running tests in looponfailing mode
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
For refactoring a project with a medium or large test suite
|
||||
you can use the looponfailing mode, simply add the ``--f`` option::
|
||||
|
||||
py.test -f
|
||||
|
||||
and py.test will run your tests, then wait for file changes and re-run the failing test set. Of course you can pass in more options to select tests or test files. File changes are detected by looking at the root directory - you can override this automatic default by an ini-file setting::
|
||||
|
||||
# content of a pytest.ini, setup.cfg or tox.ini file
|
||||
[pytest]
|
||||
looponfailroots = mypkg testdir
|
||||
|
||||
This would lead to only looking for file changes in the respective directories, specified relatively to the ini-file's directory.
|
||||
|
||||
Sending tests to remote SSH accounts
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
.. _xunitsetup:
|
||||
|
||||
====================================
|
||||
extended xUnit style setup fixtures
|
||||
====================================
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
"""
|
||||
unit and functional testing with Python.
|
||||
|
||||
see http://pytest.org for documentation and details
|
||||
|
||||
(c) Holger Krekel and others, 2004-2010
|
||||
"""
|
||||
__version__ = '2.0.0.dev38'
|
||||
__version__ = '2.0.0.dev39'
|
||||
__all__ = ['main']
|
||||
|
||||
from _pytest.core import main, UsageError, _preloadplugins
|
||||
|
|
2
setup.py
2
setup.py
|
@ -22,7 +22,7 @@ def main():
|
|||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
long_description = long_description,
|
||||
version='2.0.0.dev38',
|
||||
version='2.0.0.dev39',
|
||||
url='http://pytest.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
|
Loading…
Reference in New Issue