2010-11-25 02:02:08 +08:00
|
|
|
py.test 2.0.0: asserts++, unittest++, reporting++, config++, docs++
|
2010-11-06 18:38:53 +08:00
|
|
|
===========================================================================
|
|
|
|
|
2010-11-19 01:42:33 +08:00
|
|
|
Welcome to pytest-2.0.0, a major new release of "py.test", the rapid
|
2010-11-24 07:23:22 +08:00
|
|
|
easy Python testing tool. There are many new features and enhancements,
|
2010-11-25 02:02:08 +08:00
|
|
|
see below for summary and detailed lists. A lot of long-deprecated code
|
|
|
|
has been removed, resulting in a much smaller and cleaner
|
|
|
|
implementation. See the new docs with examples here:
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2020-07-07 18:39:35 +08:00
|
|
|
http://pytest.org/en/stable/index.html
|
2010-11-24 07:23:22 +08:00
|
|
|
|
2010-11-25 02:02:08 +08:00
|
|
|
A note on packaging: pytest used to part of the "py" distribution up
|
|
|
|
until version py-1.3.4 but this has changed now: pytest-2.0.0 only
|
|
|
|
contains py.test related code and is expected to be backward-compatible
|
|
|
|
to existing test code. If you want to install pytest, just type one of::
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2010-11-25 02:02:08 +08:00
|
|
|
pip install -U pytest
|
|
|
|
easy_install -U pytest
|
2010-11-07 05:17:33 +08:00
|
|
|
|
2010-11-25 02:02:08 +08:00
|
|
|
Many thanks to all issue reporters and people asking questions or
|
2010-11-07 05:17:33 +08:00
|
|
|
complaining. Particular thanks to Floris Bruynooghe and Ronny Pfannschmidt
|
2010-11-25 02:02:08 +08:00
|
|
|
for their great coding contributions and many others for feedback and help.
|
2010-11-07 05:17:33 +08:00
|
|
|
|
|
|
|
best,
|
2010-11-19 01:42:33 +08:00
|
|
|
holger krekel
|
2010-11-07 05:17:33 +08:00
|
|
|
|
|
|
|
|
2010-11-06 18:38:53 +08:00
|
|
|
New Features
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
- new invocations through Python interpreter and from Python::
|
|
|
|
|
2010-11-13 18:10:45 +08:00
|
|
|
python -m pytest # on all pythons >= 2.5
|
|
|
|
|
|
|
|
or from a python program::
|
|
|
|
|
2010-11-19 01:42:33 +08:00
|
|
|
import pytest ; pytest.main(arglist, pluginlist)
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2021-07-06 15:09:04 +08:00
|
|
|
see http://pytest.org/en/stable/how-to/usage.html for details.
|
2010-11-07 05:17:33 +08:00
|
|
|
|
|
|
|
- new and better reporting information in assert expressions
|
2010-11-13 18:10:45 +08:00
|
|
|
if comparing lists, sequences or strings.
|
2010-11-07 05:17:33 +08:00
|
|
|
|
2021-07-06 15:09:04 +08:00
|
|
|
see http://pytest.org/en/stable/how-to/assert.html#newreport
|
2010-11-06 18:38:53 +08:00
|
|
|
|
|
|
|
- new configuration through ini-files (setup.cfg or tox.ini recognized),
|
|
|
|
for example::
|
|
|
|
|
|
|
|
[pytest]
|
2010-11-07 05:17:33 +08:00
|
|
|
norecursedirs = .hg data* # don't ever recurse in such dirs
|
2010-11-13 18:10:45 +08:00
|
|
|
addopts = -x --pyargs # add these command line options by default
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2021-07-06 15:09:04 +08:00
|
|
|
see http://pytest.org/en/stable/reference/customize.html
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2010-11-19 01:42:33 +08:00
|
|
|
- improved standard unittest support. In general py.test should now
|
2010-11-25 02:02:08 +08:00
|
|
|
better be able to run custom unittest.TestCases like twisted trial
|
|
|
|
or Django based TestCases. Also you can now run the tests of an
|
|
|
|
installed 'unittest' package with py.test::
|
2010-11-07 05:17:33 +08:00
|
|
|
|
|
|
|
py.test --pyargs unittest
|
|
|
|
|
2010-11-13 18:10:45 +08:00
|
|
|
- new "-q" option which decreases verbosity and prints a more
|
2010-11-07 05:17:33 +08:00
|
|
|
nose/unittest-style "dot" output.
|
|
|
|
|
2010-11-25 02:02:08 +08:00
|
|
|
- many many more detailed improvements details
|
2010-11-13 18:10:45 +08:00
|
|
|
|
2010-11-07 05:17:33 +08:00
|
|
|
Fixes
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
- fix issue126 - introduce py.test.set_trace() to trace execution via
|
|
|
|
PDB during the running of tests even if capturing is ongoing.
|
|
|
|
- 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).
|
|
|
|
- fix issue88 (finding custom test nodes from command line arg)
|
|
|
|
- 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
|
|
|
|
|
2010-11-25 02:02:08 +08:00
|
|
|
Important Notes
|
2010-11-19 01:42:33 +08:00
|
|
|
--------------------
|
|
|
|
|
|
|
|
* The usual way in pre-2.0 times to use py.test in python code was
|
|
|
|
to import "py" and then e.g. use "py.test.raises" for the helper.
|
|
|
|
This remains valid and is not planned to be deprecated. However,
|
|
|
|
in most examples and internal code you'll find "import pytest"
|
|
|
|
and "pytest.raises" used as the recommended default way.
|
|
|
|
|
|
|
|
* pytest now first performs collection of the complete test suite
|
|
|
|
before running any test. This changes for example the semantics of when
|
|
|
|
pytest_collectstart/pytest_collectreport are called. Some plugins may
|
|
|
|
need upgrading.
|
2010-11-07 05:17:33 +08:00
|
|
|
|
2010-11-19 01:42:33 +08:00
|
|
|
* The pytest package consists of a 400 LOC core.py and about 20 builtin plugins,
|
|
|
|
summing up to roughly 5000 LOCs, including docstrings. To be fair, it also
|
|
|
|
uses generic code from the "pylib", and the new "py" package to help
|
|
|
|
with filesystem and introspection/code manipulation.
|
2010-11-07 05:17:33 +08:00
|
|
|
|
|
|
|
(Incompatible) Removals
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
- py.test.config is now only available if you are in a test run.
|
|
|
|
|
|
|
|
- the following (mostly already deprecated) functionality was removed:
|
2010-11-18 21:56:16 +08:00
|
|
|
|
2010-11-07 05:17:33 +08:00
|
|
|
- removed support for Module/Class/... collection node definitions
|
|
|
|
in conftest.py files. They will cause nothing special.
|
|
|
|
- removed support for calling the pre-1.0 collection API of "run()" and "join"
|
|
|
|
- removed reading option values from conftest.py files or env variables.
|
|
|
|
This can now be done much much better and easier through the ini-file
|
|
|
|
mechanism and the "addopts" entry in particular.
|
|
|
|
- removed the "disabled" attribute in test classes. Use the skipping
|
|
|
|
and pytestmark mechanism to skip or xfail a test class.
|
|
|
|
|
|
|
|
- py.test.collect.Directory does not exist anymore and it
|
|
|
|
is not possible to provide an own "Directory" object.
|
2010-11-19 01:42:33 +08:00
|
|
|
If you have used this and don't know what to do, get
|
2011-02-17 21:46:40 +08:00
|
|
|
in contact. We'll figure something out.
|
2010-11-06 18:38:53 +08:00
|
|
|
|
2010-11-07 05:17:33 +08:00
|
|
|
Note that pytest_collect_directory() is still called but
|
|
|
|
any return value will be ignored. This allows to keep
|
|
|
|
old code working that performed for example "py.test.skip()"
|
|
|
|
in collect() to prevent recursion into directory trees
|
|
|
|
if a certain dependency or command line option is missing.
|
2010-11-06 18:38:53 +08:00
|
|
|
|
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
see :ref:`changelog` for more detailed changes.
|