| 1 |
pytest-2.3: improved fixtures / better unittest integration |
| 2 |
============================================================================= |
| 3 |
|
| 4 |
pytest-2.3 comes with many major improvements for fixture/funcarg management |
| 5 |
and parametrized testing in Python. It is now easier, more efficient and |
| 6 |
more predictable to re-run the same tests with different fixture |
| 7 |
instances. Also, you can directly declare the caching "scope" of |
| 8 |
fixtures so that dependent tests throughout your whole test suite can |
| 9 |
re-use database or other expensive fixture objects with ease. Lastly, |
| 10 |
it's possible for fixture functions (formerly known as funcarg |
| 11 |
factories) to use other fixtures, allowing for a completely modular and |
| 12 |
re-usable fixture design. |
| 13 |
|
| 14 |
For detailed info and tutorial-style examples, see: |
| 15 |
|
| 16 |
http://pytest.org/en/stable/explanation/fixtures.html |
| 17 |
|
| 18 |
Moreover, there is now support for using pytest fixtures/funcargs with |
| 19 |
unittest-style suites, see here for examples: |
| 20 |
|
| 21 |
http://pytest.org/en/stable/how-to/unittest.html |
| 22 |
|
| 23 |
Besides, more unittest-test suites are now expected to "simply work" |
| 24 |
with pytest. |
| 25 |
|
| 26 |
All changes are backward compatible and you should be able to continue |
| 27 |
to run your test suites and 3rd party plugins that worked with |
| 28 |
pytest-2.2.4. |
| 29 |
|
| 30 |
If you are interested in the precise reasoning (including examples) of the |
| 31 |
pytest-2.3 fixture evolution, please consult |
| 32 |
http://pytest.org/en/stable/funcarg_compare.html |
| 33 |
|
| 34 |
For general info on installation and getting started: |
| 35 |
|
| 36 |
http://pytest.org/en/stable/getting-started.html |
| 37 |
|
| 38 |
Docs and PDF access as usual at: |
| 39 |
|
| 40 |
http://pytest.org |
| 41 |
|
| 42 |
and more details for those already in the knowing of pytest can be found |
| 43 |
in the CHANGELOG below. |
| 44 |
|
| 45 |
Particular thanks for this release go to Floris Bruynooghe, Alex Okrushko |
| 46 |
Carl Meyer, Ronny Pfannschmidt, Benjamin Peterson and Alex Gaynor for helping |
| 47 |
to get the new features right and well integrated. Ronny and Floris |
| 48 |
also helped to fix a number of bugs and yet more people helped by |
| 49 |
providing bug reports. |
| 50 |
|
| 51 |
have fun, |
| 52 |
holger krekel |
| 53 |
|
| 54 |
|
| 55 |
Changes between 2.2.4 and 2.3.0 |
| 56 |
----------------------------------- |
| 57 |
|
| 58 |
- fix issue202 - better automatic names for parametrized test functions |
| 59 |
- fix issue139 - introduce @pytest.fixture which allows direct scoping |
| 60 |
and parametrization of funcarg factories. Introduce new @pytest.setup |
| 61 |
marker to allow the writing of setup functions which accept funcargs. |
| 62 |
- fix issue198 - conftest fixtures were not found on windows32 in some |
| 63 |
circumstances with nested directory structures due to path manipulation issues |
| 64 |
- fix issue193 skip test functions with were parametrized with empty |
| 65 |
parameter sets |
| 66 |
- fix python3.3 compat, mostly reporting bits that previously depended |
| 67 |
on dict ordering |
| 68 |
- introduce re-ordering of tests by resource and parametrization setup |
| 69 |
which takes precedence to the usual file-ordering |
| 70 |
- fix issue185 monkeypatching time.time does not cause pytest to fail |
| 71 |
- fix issue172 duplicate call of pytest.setup-decoratored setup_module |
| 72 |
functions |
| 73 |
- fix junitxml=path construction so that if tests change the |
| 74 |
current working directory and the path is a relative path |
| 75 |
it is constructed correctly from the original current working dir. |
| 76 |
- fix "python setup.py test" example to cause a proper "errno" return |
| 77 |
- fix issue165 - fix broken doc links and mention stackoverflow for FAQ |
| 78 |
- catch unicode-issues when writing failure representations |
| 79 |
to terminal to prevent the whole session from crashing |
| 80 |
- fix xfail/skip confusion: a skip-mark or an imperative pytest.skip |
| 81 |
will now take precedence before xfail-markers because we |
| 82 |
can't determine xfail/xpass status in case of a skip. see also: |
| 83 |
http://stackoverflow.com/questions/11105828/in-py-test-when-i-explicitly-skip-a-test-that-is-marked-as-xfail-how-can-i-get |
| 84 |
|
| 85 |
- always report installed 3rd party plugins in the header of a test run |
| 86 |
|
| 87 |
- fix issue160: a failing setup of an xfail-marked tests should |
| 88 |
be reported as xfail (not xpass) |
| 89 |
|
| 90 |
- fix issue128: show captured output when capsys/capfd are used |
| 91 |
|
| 92 |
- fix issue179: properly show the dependency chain of factories |
| 93 |
|
| 94 |
- pluginmanager.register(...) now raises ValueError if the |
| 95 |
plugin has been already registered or the name is taken |
| 96 |
|
| 97 |
- fix issue159: improve https://docs.pytest.org/en/6.0.1/faq.html |
| 98 |
especially with respect to the "magic" history, also mention |
| 99 |
pytest-django, trial and unittest integration. |
| 100 |
|
| 101 |
- make request.keywords and node.keywords writable. All descendant |
| 102 |
collection nodes will see keyword values. Keywords are dictionaries |
| 103 |
containing markers and other info. |
| 104 |
|
| 105 |
- fix issue 178: xml binary escapes are now wrapped in py.xml.raw |
| 106 |
|
| 107 |
- fix issue 176: correctly catch the builtin AssertionError |
| 108 |
even when we replaced AssertionError with a subclass on the |
| 109 |
python level |
| 110 |
|
| 111 |
- factory discovery no longer fails with magic global callables |
| 112 |
that provide no sane __code__ object (mock.call for example) |
| 113 |
|
| 114 |
- fix issue 182: testdir.inprocess_run now considers passed plugins |
| 115 |
|
| 116 |
- fix issue 188: ensure sys.exc_info is clear on python2 |
| 117 |
before calling into a test |
| 118 |
|
| 119 |
- fix issue 191: add unittest TestCase runTest method support |
| 120 |
- fix issue 156: monkeypatch correctly handles class level descriptors |
| 121 |
|
| 122 |
- reporting refinements: |
| 123 |
|
| 124 |
- pytest_report_header now receives a "startdir" so that |
| 125 |
you can use startdir.bestrelpath(yourpath) to show |
| 126 |
nice relative path |
| 127 |
|
| 128 |
- allow plugins to implement both pytest_report_header and |
| 129 |
pytest_sessionstart (sessionstart is invoked first). |
| 130 |
|
| 131 |
- don't show deselected reason line if there is none |
| 132 |
|
| 133 |
- py.test -vv will show all of assert comparisons instead of truncating |