diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1c1185dc0..f033f8cab 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,172 @@ .. towncrier release notes start +Pytest 3.2.0 (2017-07-30) +========================= + +Deprecations and Removals +------------------------- + +- ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=`` + operators to avoid surprising/inconsistent behavior. See `the docs + `_ for more + information. (`#2003 `_) + +- All old-style specific behavior in current classes in the pytest's API is + considered deprecated at this point and will be removed in a future release. + This affects Python 2 users only and in rare situations. (`#2147 + `_) + +- A deprecation warning is now raised when using marks for parameters + in ``pytest.mark.parametrize``. Use ``pytest.param`` to apply marks to + parameters instead. (`#2427 `_) + + +Features +-------- + +- Add support for numpy arrays (and dicts) to approx. (`#1994 + `_) + +- Now test function objects have a ``pytestmark`` attribute containing a list + of marks applied directly to the test function, as opposed to marks inherited + from parent classes or modules. (`#2516 `_) + +- Collection ignores local virtualenvs by default; `--collect-in-virtualenv` + overrides this behavior. (`#2518 `_) + +- Allow class methods decorated as ``@staticmethod`` to be candidates for + collection as a test function. (Only for Python 2.7 and above. Python 2.6 + will still ignore static methods.) (`#2528 `_) + +- Introduce ``mark.with_args`` in order to allow passing functions/classes as + sole argument to marks. (`#2540 `_) + +- New ``cache_dir`` ini option: sets the directory where the contents of the + cache plugin are stored. Directory may be relative or absolute path: if relative path, then + directory is created relative to ``rootdir``, otherwise it is used as is. + Additionally path may contain environment variables which are expanded during + runtime. (`#2543 `_) + +- Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with + the ``nodeid`` and stage (``setup``, ``call`` and ``teardown``) of the test + being currently executed. See the `documentation + `_ for more info. (`#2583 `_) + +- Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the + warnings filter on a per test, class or module level. See the `docs + `_ for more information. (`#2598 `_) + +- ``--last-failed`` now remembers forever when a test has failed and only + forgets it if it passes again. This makes it easy to fix a test suite by + selectively running files and fixing tests incrementally. (`#2621 + `_) + +- New ``pytest_report_collectionfinish`` hook which allows plugins to add + messages to the terminal reporting after collection has been finished + successfully. (`#2622 `_) + +- Added support for `PEP-415's `_ + ``Exception.__suppress_context__``. Now if a ``raise exception from None`` is + caught by pytest, pytest will no longer chain the context in the test report. + The behavior now matches Python's traceback behavior. (`#2631 + `_) + +- Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail`` + now subclass BaseException, making them harder to be caught unintentionally + by normal code. (`#580 `_) + + +Bug Fixes +--------- + +- Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for + avoid unwanted interactive ``pdb`` (`#2023 `_) + +- Add missing ``encoding`` attribute to ``sys.std*`` streams when using + ``capsys`` capture mode. (`#2375 `_) + +- Fix terminal color changing to black on Windows if ``colorama`` is imported + in a ``conftest.py`` file. (`#2510 `_) + +- Fix line number when reporting summary of skipped tests. (`#2548 + `_) + +- capture: ensure that EncodedFile.name is a string. (`#2555 + `_) + +- The options ```--fixtures`` and ```--fixtures-per-test`` will now keep + indentation within docstrings. (`#2574 `_) + +- doctests line numbers are now reported correctly, fixing `pytest-sugar#122 + `_. (`#2610 + `_) + +- Fix non-determinism in order of fixture collection. Adds new dependency + (ordereddict) for Python 2.6. (`#920 `_) + + +Improved Documentation +---------------------- + +- Clarify ``pytest_configure`` hook call order. (`#2539 + `_) + +- Extend documentation for testing plugin code with the ``pytester`` plugin. + (`#971 `_) + + +Trivial/Internal Changes +------------------------ + +- Update help message for ``--strict`` to make it clear it only deals with + unregistered markers, not warnings. (`#2444 `_) + +- Internal code move: move code for pytest.approx/pytest.raises to own files in + order to cut down the size of python.py (`#2489 `_) + +- Renamed the utility function ``_pytest.compat._escape_strings`` to + ``_ascii_escaped`` to better communicate the function's purpose. (`#2533 + `_) + +- Improve error message for CollectError with skip/skipif. (`#2546 + `_) + +- Emit warning about ``yield`` tests being deprecated only once per generator. + (`#2562 `_) + +- Ensure final collected line doesn't include artifacts of previous write. + (`#2571 `_) + +- Fixed all flake8 errors and warnings. (`#2581 `_) + +- Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code. + (`#2582 `_) + +- Turn warnings into errors in pytest's own test suite in order to catch + regressions due to deprecations more promptly. (`#2588 + `_) + +- Show multiple issue links in CHANGELOG entries. (`#2620 + `_) + + Pytest 3.1.3 (2017-07-03) ========================= diff --git a/HOWTORELEASE.rst b/HOWTORELEASE.rst index f094e369a..c85fd9b99 100644 --- a/HOWTORELEASE.rst +++ b/HOWTORELEASE.rst @@ -54,7 +54,7 @@ How to release pytest where PYPI_NAME is the name of pypi.python.org as configured in your ``~/.pypirc`` file `for devpi `_. -#. After a minor/major release, merge ``features`` into ``master`` and push (or open a PR). +#. After a minor/major release, merge ``release-X.Y.Z`` into ``master`` and push (or open a PR). .. _devpi-cloud-test: https://github.com/obestwalter/devpi-cloud-test .. _AppVeyor: https://www.appveyor.com/ diff --git a/changelog/1994.feature b/changelog/1994.feature deleted file mode 100644 index f3c596e63..000000000 --- a/changelog/1994.feature +++ /dev/null @@ -1 +0,0 @@ -Add support for numpy arrays (and dicts) to approx. diff --git a/changelog/2003.removal b/changelog/2003.removal deleted file mode 100644 index d3269bf4e..000000000 --- a/changelog/2003.removal +++ /dev/null @@ -1,2 +0,0 @@ -``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=`` operators to avoid surprising/inconsistent -behavior. See `the docs `_ for more information. diff --git a/changelog/2023.bugfix b/changelog/2023.bugfix deleted file mode 100644 index acf4b405b..000000000 --- a/changelog/2023.bugfix +++ /dev/null @@ -1 +0,0 @@ -Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for avoid unwanted interactive ``pdb`` diff --git a/changelog/2147.removal b/changelog/2147.removal deleted file mode 100644 index d5f80a108..000000000 --- a/changelog/2147.removal +++ /dev/null @@ -1 +0,0 @@ -All old-style specific behavior in current classes in the pytest's API is considered deprecated at this point and will be removed in a future release. This affects Python 2 users only and in rare situations. diff --git a/changelog/2375.bugfix b/changelog/2375.bugfix deleted file mode 100644 index 3f4fd3c3d..000000000 --- a/changelog/2375.bugfix +++ /dev/null @@ -1 +0,0 @@ -Add missing ``encoding`` attribute to ``sys.std*`` streams when using ``capsys`` capture mode. diff --git a/changelog/2427.removal b/changelog/2427.removal deleted file mode 100644 index c7ed8e17a..000000000 --- a/changelog/2427.removal +++ /dev/null @@ -1 +0,0 @@ -introduce deprecation warnings for legacy marks based parametersets diff --git a/changelog/2444.trivial b/changelog/2444.trivial deleted file mode 100644 index 4d6e2de5b..000000000 --- a/changelog/2444.trivial +++ /dev/null @@ -1 +0,0 @@ -Update help message for ``--strict`` to make it clear it only deals with unregistered markers, not warnings. diff --git a/changelog/2489.trivial b/changelog/2489.trivial deleted file mode 100644 index c997d7e1e..000000000 --- a/changelog/2489.trivial +++ /dev/null @@ -1 +0,0 @@ -Internal code move: move code for pytest.approx/pytest.raises to own files in order to cut down the size of python.py \ No newline at end of file diff --git a/changelog/2510.bugfix b/changelog/2510.bugfix deleted file mode 100644 index e6fcb7c74..000000000 --- a/changelog/2510.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix terminal color changing to black on Windows if ``colorama`` is imported in a ``conftest.py`` file. diff --git a/changelog/2516.feature b/changelog/2516.feature deleted file mode 100644 index 6436de16a..000000000 --- a/changelog/2516.feature +++ /dev/null @@ -1 +0,0 @@ -Now test function objects have a ``pytestmark`` attribute containing a list of marks applied directly to the test function, as opposed to marks inherited from parent classes or modules. \ No newline at end of file diff --git a/changelog/2518.feature b/changelog/2518.feature deleted file mode 100644 index 2f6597a97..000000000 --- a/changelog/2518.feature +++ /dev/null @@ -1 +0,0 @@ -Collection ignores local virtualenvs by default; `--collect-in-virtualenv` overrides this behavior. diff --git a/changelog/2528.feature b/changelog/2528.feature deleted file mode 100644 index c91cdb5d7..000000000 --- a/changelog/2528.feature +++ /dev/null @@ -1 +0,0 @@ -Allow class methods decorated as ``@staticmethod`` to be candidates for collection as a test function. (Only for Python 2.7 and above. Python 2.6 will still ignore static methods.) diff --git a/changelog/2533.trivial b/changelog/2533.trivial deleted file mode 100644 index 930fd4c0d..000000000 --- a/changelog/2533.trivial +++ /dev/null @@ -1 +0,0 @@ -Renamed the utility function ``_pytest.compat._escape_strings`` to ``_ascii_escaped`` to better communicate the function's purpose. diff --git a/changelog/2539.doc b/changelog/2539.doc deleted file mode 100644 index 6d5a9c9db..000000000 --- a/changelog/2539.doc +++ /dev/null @@ -1 +0,0 @@ -Clarify ``pytest_configure`` hook call order. diff --git a/changelog/2540.feature b/changelog/2540.feature deleted file mode 100644 index d65b1ea56..000000000 --- a/changelog/2540.feature +++ /dev/null @@ -1 +0,0 @@ -Introduce ``mark.with_args`` in order to allow passing functions/classes as sole argument to marks. \ No newline at end of file diff --git a/changelog/2543.feature b/changelog/2543.feature deleted file mode 100644 index 6d65a376f..000000000 --- a/changelog/2543.feature +++ /dev/null @@ -1 +0,0 @@ -New ``cache_dir`` ini option: sets a directory where stores content of cache plugin. Default directory is ``.cache`` which is created in ``rootdir``. Directory may be relative or absolute path. If setting relative path, then directory is created relative to ``rootdir``. Additionally path may contain environment variables, that will be expanded. diff --git a/changelog/2546.trivial b/changelog/2546.trivial deleted file mode 100644 index 53e43bc17..000000000 --- a/changelog/2546.trivial +++ /dev/null @@ -1 +0,0 @@ -Improve error message for CollectError with skip/skipif. diff --git a/changelog/2548.bugfix b/changelog/2548.bugfix deleted file mode 100644 index 8201594ed..000000000 --- a/changelog/2548.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix line number when reporting summary of skipped tests. diff --git a/changelog/2555.bugfix b/changelog/2555.bugfix deleted file mode 100644 index 8c20bbc67..000000000 --- a/changelog/2555.bugfix +++ /dev/null @@ -1 +0,0 @@ -capture: ensure that EncodedFile.name is a string. diff --git a/changelog/2562.trivial b/changelog/2562.trivial deleted file mode 100644 index 33e34ff65..000000000 --- a/changelog/2562.trivial +++ /dev/null @@ -1 +0,0 @@ -Emit warning about ``yield`` tests being deprecated only once per generator. diff --git a/changelog/2571.trivial b/changelog/2571.trivial deleted file mode 100644 index 45750f122..000000000 --- a/changelog/2571.trivial +++ /dev/null @@ -1 +0,0 @@ -Ensure final collected line doesn't include artifacts of previous write. diff --git a/changelog/2574.bugfix b/changelog/2574.bugfix deleted file mode 100644 index 13396bc16..000000000 --- a/changelog/2574.bugfix +++ /dev/null @@ -1 +0,0 @@ -The options ```--fixtures`` and ```--fixtures-per-test`` will now keep indentation within docstrings. diff --git a/changelog/2581.trivial b/changelog/2581.trivial deleted file mode 100644 index 341ef337f..000000000 --- a/changelog/2581.trivial +++ /dev/null @@ -1 +0,0 @@ -Fixed all flake8 errors and warnings. diff --git a/changelog/2582.trivial b/changelog/2582.trivial deleted file mode 100644 index a4e0793e4..000000000 --- a/changelog/2582.trivial +++ /dev/null @@ -1 +0,0 @@ -Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code. diff --git a/changelog/2583.feature b/changelog/2583.feature deleted file mode 100644 index 315f2378e..000000000 --- a/changelog/2583.feature +++ /dev/null @@ -1,2 +0,0 @@ -Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with the ``nodeid`` and stage (``setup``, ``call`` and -``teardown``) of the test being currently executed. See the `documentation `_ for more info. diff --git a/changelog/2588.trivial b/changelog/2588.trivial deleted file mode 100644 index 44ff69f74..000000000 --- a/changelog/2588.trivial +++ /dev/null @@ -1 +0,0 @@ -Turn warnings into errors in pytest's own test suite in order to catch regressions due to deprecations more promptly. diff --git a/changelog/2598.feature b/changelog/2598.feature deleted file mode 100644 index b811b9120..000000000 --- a/changelog/2598.feature +++ /dev/null @@ -1,2 +0,0 @@ -Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the warnings filter on a per test, class or module level. -See the `docs `_ for more information. diff --git a/changelog/2610.bugfix b/changelog/2610.bugfix deleted file mode 100644 index 3757723e0..000000000 --- a/changelog/2610.bugfix +++ /dev/null @@ -1 +0,0 @@ -doctests line numbers are now reported correctly, fixing `pytest-sugar#122 `_. diff --git a/changelog/2620.trivial b/changelog/2620.trivial deleted file mode 100644 index 51c0bd160..000000000 --- a/changelog/2620.trivial +++ /dev/null @@ -1 +0,0 @@ -Show multiple issue links in CHANGELOG entries. diff --git a/changelog/2621.feature b/changelog/2621.feature deleted file mode 100644 index 19ca96355..000000000 --- a/changelog/2621.feature +++ /dev/null @@ -1,2 +0,0 @@ -``--last-failed`` now remembers forever when a test has failed and only forgets it if it passes again. This makes it -easy to fix a test suite by selectively running files and fixing tests incrementally. diff --git a/changelog/2622.feature b/changelog/2622.feature deleted file mode 100644 index 298892200..000000000 --- a/changelog/2622.feature +++ /dev/null @@ -1,2 +0,0 @@ -New ``pytest_report_collectionfinish`` hook which allows plugins to add messages to the terminal reporting after -collection has been finished successfully. diff --git a/changelog/2631.feature b/changelog/2631.feature deleted file mode 100644 index 91b903b17..000000000 --- a/changelog/2631.feature +++ /dev/null @@ -1,4 +0,0 @@ -Added support for `PEP-415's `_ -``Exception.__suppress_context__``. Now if a ``raise exception from None`` is -caught by pytest, pytest will no longer chain the context in the test report. -The behavior now matches Python's traceback behavior. diff --git a/changelog/580.feature b/changelog/580.feature deleted file mode 100644 index 5245c7341..000000000 --- a/changelog/580.feature +++ /dev/null @@ -1 +0,0 @@ -Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail`` now subclass BaseException, making them harder to be caught unintentionally by normal code. \ No newline at end of file diff --git a/changelog/920.bugfix b/changelog/920.bugfix deleted file mode 100644 index d2dd2be1b..000000000 --- a/changelog/920.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix non-determinism in order of fixture collection. Adds new dependency (ordereddict) for Python 2.6. diff --git a/changelog/971.doc b/changelog/971.doc deleted file mode 100644 index e182cf8ee..000000000 --- a/changelog/971.doc +++ /dev/null @@ -1 +0,0 @@ -Extend documentation for testing plugin code with the ``pytester`` plugin. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 5061f4870..8a2f15d8d 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-3.2.0 release-3.1.3 release-3.1.2 release-3.1.1 diff --git a/doc/en/announce/release-3.2.0.rst b/doc/en/announce/release-3.2.0.rst new file mode 100644 index 000000000..4d2830edd --- /dev/null +++ b/doc/en/announce/release-3.2.0.rst @@ -0,0 +1,48 @@ +pytest-3.2.0 +======================================= + +The pytest team is proud to announce the 3.2.0 release! + +pytest is a mature Python testing tool with more than a 1600 tests +against itself, passing on many different interpreters and platforms. + +This release contains a number of bugs fixes and improvements, so users are encouraged +to take a look at the CHANGELOG: + + http://doc.pytest.org/en/latest/changelog.html + +For complete documentation, please visit: + + http://docs.pytest.org + +As usual, you can upgrade from pypi via: + + pip install -U pytest + +Thanks to all who contributed to this release, among them: + +* Alex Hartoto +* Andras Tim +* Bruno Oliveira +* Daniel Hahler +* Florian Bruhin +* Floris Bruynooghe +* John Still +* Jordan Moldow +* Kale Kundert +* Lawrence Mitchell +* Llandy Riveron Del Risco +* Maik Figura +* Martin Altmayer +* Mihai Capotă +* Nathaniel Waisbrot +* Nguyễn Hồng Quân +* Pauli Virtanen +* Raphael Pierzina +* Ronny Pfannschmidt +* Segev Finer +* V.Kuznetsov + + +Happy testing, +The Pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index a3b75b9b2..b59399a79 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -108,14 +108,14 @@ You can ask for available builtin or project-custom The returned ``monkeypatch`` fixture provides these helper methods to modify objects, dictionaries or os.environ:: - monkeypatch.setattr(obj, name, value, raising=True) - monkeypatch.delattr(obj, name, raising=True) - monkeypatch.setitem(mapping, name, value) - monkeypatch.delitem(obj, name, raising=True) - monkeypatch.setenv(name, value, prepend=False) - monkeypatch.delenv(name, value, raising=True) - monkeypatch.syspath_prepend(path) - monkeypatch.chdir(path) + monkeypatch.setattr(obj, name, value, raising=True) + monkeypatch.delattr(obj, name, raising=True) + monkeypatch.setitem(mapping, name, value) + monkeypatch.delitem(obj, name, raising=True) + monkeypatch.setenv(name, value, prepend=False) + monkeypatch.delenv(name, value, raising=True) + monkeypatch.syspath_prepend(path) + monkeypatch.chdir(path) All modifications will be undone after the requesting test function or fixture has finished. The ``raising`` diff --git a/doc/en/cache.rst b/doc/en/cache.rst index ac7a855fc..d5d6b653b 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -77,9 +77,9 @@ If you then run it with ``--lf``:: $ pytest --lf ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y - run-last-failure: rerun last 2 failures rootdir: $REGENDOC_TMPDIR, inifile: collected 50 items + run-last-failure: rerun previous 2 failures test_50.py FF @@ -119,9 +119,9 @@ of ``FF`` and dots):: $ pytest --ff ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y - run-last-failure: rerun last 2 failures first rootdir: $REGENDOC_TMPDIR, inifile: collected 50 items + run-last-failure: rerun previous 2 failures first test_50.py FF................................................ diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index d2c38fa81..52627245c 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -494,7 +494,7 @@ then you will see two tests skipped and two executed tests as expected:: test_plat.py s.s. ======= short test summary info ======== - SKIP [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux + SKIP [2] $REGENDOC_TMPDIR/conftest.py:13: cannot run on platform linux ======= 2 passed, 2 skipped in 0.12 seconds ======== diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 2f2a11e6c..b72e8e6de 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -413,7 +413,7 @@ Running it results in some skips if we don't have all the python interpreters in . $ pytest -rs -q multipython.py sssssssssssssss.........sss.........sss......... ======= short test summary info ======== - SKIP [21] $REGENDOC_TMPDIR/CWD/multipython.py:23: 'python2.6' not found + SKIP [21] $REGENDOC_TMPDIR/CWD/multipython.py:24: 'python2.6' not found 27 passed, 21 skipped in 0.12 seconds Indirect parametrization of optional implementations/imports @@ -467,7 +467,7 @@ If you run this with reporting for skips enabled:: test_module.py .s ======= short test summary info ======== - SKIP [1] $REGENDOC_TMPDIR/conftest.py:10: could not import 'opt2' + SKIP [1] $REGENDOC_TMPDIR/conftest.py:11: could not import 'opt2' ======= 1 passed, 1 skipped in 0.12 seconds ======== diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 47c18851d..7508d726f 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -358,7 +358,7 @@ get on the terminal - we are working on that):: > int(s) E ValueError: invalid literal for int() with base 10: 'qwe' - <0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python.py:1219>:1: ValueError + <0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python_api.py:570>:1: ValueError _______ TestRaises.test_raises_doesnt ________ self = diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 6b5d5a868..f76d39264 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -170,7 +170,7 @@ and when running it will see a skipped "slow" test:: test_module.py .s ======= short test summary info ======== - SKIP [1] test_module.py:13: need --runslow option to run + SKIP [1] test_module.py:14: need --runslow option to run ======= 1 passed, 1 skipped in 0.12 seconds ======== diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 5cde906fa..d1d47c229 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -195,7 +195,7 @@ list:: $ pytest -q -rs test_strings.py s ======= short test summary info ======== - SKIP [1] test_strings.py:1: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1 + SKIP [1] test_strings.py:2: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1 1 skipped in 0.12 seconds For further examples, you might want to look at :ref:`more