| 1 |
py.test 2.2.0: test marking++, parametrization++ and duration profiling |
| 2 |
=========================================================================== |
| 3 |
|
| 4 |
pytest-2.2.0 is a test-suite compatible release of the popular |
| 5 |
py.test testing tool. Plugins might need upgrades. It comes |
| 6 |
with these improvements: |
| 7 |
|
| 8 |
* easier and more powerful parametrization of tests: |
| 9 |
|
| 10 |
- new @pytest.mark.parametrize decorator to run tests with different arguments |
| 11 |
- new metafunc.parametrize() API for parametrizing arguments independently |
| 12 |
- see examples at http://pytest.org/en/stable/example/how-to/parametrize.html |
| 13 |
- NOTE that parametrize() related APIs are still a bit experimental |
| 14 |
and might change in future releases. |
| 15 |
|
| 16 |
* improved handling of test markers and refined marking mechanism: |
| 17 |
|
| 18 |
- "-m markexpr" option for selecting tests according to their mark |
| 19 |
- a new "markers" ini-variable for registering test markers for your project |
| 20 |
- the new "--strict" bails out with an error if using unregistered markers. |
| 21 |
- see examples at http://pytest.org/en/stable/example/markers.html |
| 22 |
|
| 23 |
* duration profiling: new "--duration=N" option showing the N slowest test |
| 24 |
execution or setup/teardown calls. This is most useful if you want to |
| 25 |
find out where your slowest test code is. |
| 26 |
|
| 27 |
* also 2.2.0 performs more eager calling of teardown/finalizers functions |
| 28 |
resulting in better and more accurate reporting when they fail |
| 29 |
|
| 30 |
Besides there is the usual set of bug fixes along with a cleanup of |
| 31 |
pytest's own test suite allowing it to run on a wider range of environments. |
| 32 |
|
| 33 |
For general information, see extensive docs with examples here: |
| 34 |
|
| 35 |
http://pytest.org/ |
| 36 |
|
| 37 |
If you want to install or upgrade pytest you might just type:: |
| 38 |
|
| 39 |
pip install -U pytest # or |
| 40 |
easy_install -U pytest |
| 41 |
|
| 42 |
Thanks to Ronny Pfannschmidt, David Burns, Jeff Donner, Daniel Nouri, Alfredo Deza and all who gave feedback or sent bug reports. |
| 43 |
|
| 44 |
best, |
| 45 |
holger krekel |
| 46 |
|
| 47 |
|
| 48 |
notes on incompatibility |
| 49 |
------------------------------ |
| 50 |
|
| 51 |
While test suites should work unchanged you might need to upgrade plugins: |
| 52 |
|
| 53 |
* You need a new version of the pytest-xdist plugin (1.7) for distributing |
| 54 |
test runs. |
| 55 |
|
| 56 |
* Other plugins might need an upgrade if they implement |
| 57 |
the ``pytest_runtest_logreport`` hook which now is called unconditionally |
| 58 |
for the setup/teardown fixture phases of a test. You may choose to |
| 59 |
ignore setup/teardown failures by inserting "if rep.when != 'call': return" |
| 60 |
or something similar. Note that most code probably "just" works because |
| 61 |
the hook was already called for failing setup/teardown phases of a test |
| 62 |
so a plugin should have been ready to grok such reports already. |
| 63 |
|
| 64 |
|
| 65 |
Changes between 2.1.3 and 2.2.0 |
| 66 |
---------------------------------------- |
| 67 |
|
| 68 |
- fix issue90: introduce eager tearing down of test items so that |
| 69 |
teardown function are called earlier. |
| 70 |
- add an all-powerful metafunc.parametrize function which allows to |
| 71 |
parametrize test function arguments in multiple steps and therefore |
| 72 |
from independent plugins and places. |
| 73 |
- add a @pytest.mark.parametrize helper which allows to easily |
| 74 |
call a test function with different argument values. |
| 75 |
- Add examples to the "parametrize" example page, including a quick port |
| 76 |
of Test scenarios and the new parametrize function and decorator. |
| 77 |
- introduce registration for "pytest.mark.*" helpers via ini-files |
| 78 |
or through plugin hooks. Also introduce a "--strict" option which |
| 79 |
will treat unregistered markers as errors |
| 80 |
allowing to avoid typos and maintain a well described set of markers |
| 81 |
for your test suite. See examples at http://pytest.org/en/stable/how-to/mark.html |
| 82 |
and its links. |
| 83 |
- issue50: introduce "-m marker" option to select tests based on markers |
| 84 |
(this is a stricter and more predictable version of "-k" in that "-m" |
| 85 |
only matches complete markers and has more obvious rules for and/or |
| 86 |
semantics. |
| 87 |
- new feature to help optimizing the speed of your tests: |
| 88 |
--durations=N option for displaying N slowest test calls |
| 89 |
and setup/teardown methods. |
| 90 |
- fix issue87: --pastebin now works with python3 |
| 91 |
- fix issue89: --pdb with unexpected exceptions in doctest work more sensibly |
| 92 |
- fix and cleanup pytest's own test suite to not leak FDs |
| 93 |
- fix issue83: link to generated funcarg list |
| 94 |
- fix issue74: pyarg module names are now checked against imp.find_module false positives |
| 95 |
- fix compatibility with twisted/trial-11.1.0 use cases |