From 329f56ecec5a9fcbfa160d4b467342a7c19ef2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=8E=AE?= Date: Sat, 16 Nov 2019 14:49:17 +0800 Subject: [PATCH 01/11] Fix incorrect result of getmodpath method. --- AUTHORS | 1 + changelog/6189.bugfix.rst | 1 + src/_pytest/python.py | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/6189.bugfix.rst diff --git a/AUTHORS b/AUTHORS index d0e584f63..c10ee5c15 100644 --- a/AUTHORS +++ b/AUTHORS @@ -261,6 +261,7 @@ Virgil Dupras Vitaly Lashmanov Vlad Dragos Volodymyr Piskun +Wei Lin Wil Cooley William Lee Wim Glenn diff --git a/changelog/6189.bugfix.rst b/changelog/6189.bugfix.rst new file mode 100644 index 000000000..060a2260a --- /dev/null +++ b/changelog/6189.bugfix.rst @@ -0,0 +1 @@ +Fix incorrect result of ``getmodpath`` method. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index b8b365ad3..734a92f9b 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -285,8 +285,7 @@ class PyobjMixin(PyobjContext): break parts.append(name) parts.reverse() - s = ".".join(parts) - return s.replace(".[", "[") + return ".".join(parts) def reportinfo(self): # XXX caching? From 9c681b45e39a144f8c80abbd66eb4db0e185a238 Mon Sep 17 00:00:00 2001 From: TH3CHARLie Date: Sat, 16 Nov 2019 17:34:05 +0800 Subject: [PATCH 02/11] change: #3985 also introduce --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b1a988de8..47356d1d9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1901,7 +1901,8 @@ Features live-logging is enabled and/or when they are logged to a file. -- `#3985 `_: Introduce ``tmp_path`` as a fixture providing a Path object. +- `#3985 `_: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as + a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test. - `#4013 `_: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version From b090ac62048990cc4d54dab841e81a8921b97284 Mon Sep 17 00:00:00 2001 From: TH3CHARLie Date: Sat, 16 Nov 2019 18:01:08 +0800 Subject: [PATCH 03/11] remove trailing-whitespace --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 47356d1d9..e9ac09c8e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1901,7 +1901,7 @@ Features live-logging is enabled and/or when they are logged to a file. -- `#3985 `_: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as +- `#3985 `_: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test. From 9e759010d9e9bf6ff10766c54f37bdb6ce1266c2 Mon Sep 17 00:00:00 2001 From: JoshKarpel Date: Sun, 17 Nov 2019 16:45:42 -0600 Subject: [PATCH 04/11] resolve #2049 --- src/_pytest/setupplan.py | 3 +- testing/python/setup_plan.py | 103 +++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) diff --git a/src/_pytest/setupplan.py b/src/_pytest/setupplan.py index 697746f20..6fdd3aed0 100644 --- a/src/_pytest/setupplan.py +++ b/src/_pytest/setupplan.py @@ -16,7 +16,8 @@ def pytest_addoption(parser): def pytest_fixture_setup(fixturedef, request): # Will return a dummy fixture if the setuponly option is provided. if request.config.option.setupplan: - fixturedef.cached_result = (None, None, None) + my_cache_key = fixturedef.cache_key(request) + fixturedef.cached_result = (None, my_cache_key, None) return fixturedef.cached_result diff --git a/testing/python/setup_plan.py b/testing/python/setup_plan.py index e323ba240..8ff8bfc45 100644 --- a/testing/python/setup_plan.py +++ b/testing/python/setup_plan.py @@ -17,3 +17,106 @@ def test_show_fixtures_and_test(testdir, dummy_yaml_custom_test): result.stdout.fnmatch_lines( ["*SETUP F arg*", "*test_arg (fixtures used: arg)", "*TEARDOWN F arg*"] ) + + +def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir): + """ + Verify that when a fixture lives for longer than a single test, --setup-plan + correctly displays the SETUP/TEARDOWN indicators the right number of times. + + As reported in https://github.com/pytest-dev/pytest/issues/2049 + --setup-plan was showing SETUP/TEARDOWN on every test, even when the fixture + should persist through multiple tests. + + (Note that this bug never affected actual test execution, which used the + correct fixture lifetimes. It was purely a display bug for --setup-plan, and + did not affect the related --setup-show or --setup-only.) + """ + testdir.makepyfile( + """ + import pytest + + @pytest.fixture(scope = 'class') + def fix(): + return object() + + class TestClass: + def test_one(self, fix): + assert False + + def test_two(self, fix): + assert False + """ + ) + + result = testdir.runpytest("--setup-plan") + assert result.ret == 0 + + setup_fragment = "SETUP C fix" + setup_count = 0 + + teardown_fragment = "TEARDOWN C fix" + teardown_count = 0 + + for line in result.stdout.lines: + if setup_fragment in line: + setup_count += 1 + if teardown_fragment in line: + teardown_count += 1 + + # before the fix this tests, there would have been a setup/teardown + # message for each test, so the counts would each have been 2 + assert setup_count == 1 + assert teardown_count == 1 + + +def test_show_multi_test_fixture_setup_and_teardown_same_as_setup_show(testdir): + """ + Verify that SETUP/TEARDOWN messages match what comes out of --setup-show. + """ + testdir.makepyfile( + """ + import pytest + + @pytest.fixture(scope = 'session') + def sess(): + return True + + @pytest.fixture(scope = 'module') + def mod(): + return True + + @pytest.fixture(scope = 'class') + def cls(): + return True + + @pytest.fixture(scope = 'function') + def func(): + return True + + + def test_outside(sess, mod, cls, func): + assert True + + + class TestCls: + def test_one(self, sess, mod, cls, func): + assert True + + def test_two(self, sess, mod, cls, func): + assert True + """ + ) + + plan_result = testdir.runpytest("--setup-plan") + show_result = testdir.runpytest("--setup-show") + + # the number and text of these lines should be identical + plan_lines = [ + l for l in plan_result.stdout.lines if "SETUP" in l or "TEARDOWN" in l + ] + show_lines = [ + l for l in show_result.stdout.lines if "SETUP" in l or "TEARDOWN" in l + ] + + assert plan_lines == show_lines From 6dfd683a0c34535c79b6baccdc60d301c64b4f76 Mon Sep 17 00:00:00 2001 From: JoshKarpel Date: Sun, 17 Nov 2019 16:47:09 -0600 Subject: [PATCH 05/11] changelog entry for #2049 --- AUTHORS | 1 + changelog/2049.bugfix.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 changelog/2049.bugfix.rst diff --git a/AUTHORS b/AUTHORS index d0e584f63..b9e6f7271 100644 --- a/AUTHORS +++ b/AUTHORS @@ -128,6 +128,7 @@ Jeff Widman Jenni Rinker John Eddie Ayson John Towler +Josh Karpel Jon Sonesen Jonas Obrist Jordan Guymon diff --git a/changelog/2049.bugfix.rst b/changelog/2049.bugfix.rst new file mode 100644 index 000000000..395396bd3 --- /dev/null +++ b/changelog/2049.bugfix.rst @@ -0,0 +1 @@ +Fix ``-setup-plan`` showing inaccurate information about fixture lifetimes. From 1e3be8ada4585ba279cfc24be8c3b09b25213804 Mon Sep 17 00:00:00 2001 From: JoshKarpel Date: Sun, 17 Nov 2019 17:14:17 -0600 Subject: [PATCH 06/11] fix whitespace issues in tests for #2049 --- testing/python/setup_plan.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/testing/python/setup_plan.py b/testing/python/setup_plan.py index 8ff8bfc45..a44474dd1 100644 --- a/testing/python/setup_plan.py +++ b/testing/python/setup_plan.py @@ -35,15 +35,12 @@ def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir): testdir.makepyfile( """ import pytest - @pytest.fixture(scope = 'class') def fix(): return object() - class TestClass: def test_one(self, fix): assert False - def test_two(self, fix): assert False """ @@ -77,32 +74,23 @@ def test_show_multi_test_fixture_setup_and_teardown_same_as_setup_show(testdir): testdir.makepyfile( """ import pytest - @pytest.fixture(scope = 'session') def sess(): return True - @pytest.fixture(scope = 'module') def mod(): return True - @pytest.fixture(scope = 'class') def cls(): return True - @pytest.fixture(scope = 'function') def func(): return True - - def test_outside(sess, mod, cls, func): assert True - - class TestCls: def test_one(self, sess, mod, cls, func): assert True - def test_two(self, sess, mod, cls, func): assert True """ From 46ffdf0e3a98bbb6ecb2393ee706ed8250f56ade Mon Sep 17 00:00:00 2001 From: Josh Karpel Date: Sun, 17 Nov 2019 17:17:47 -0600 Subject: [PATCH 07/11] Update AUTHORS --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index b9e6f7271..1f136d83e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -128,13 +128,13 @@ Jeff Widman Jenni Rinker John Eddie Ayson John Towler -Josh Karpel Jon Sonesen Jonas Obrist Jordan Guymon Jordan Moldow Jordan Speicher Joseph Hunkeler +Josh Karpel Joshua Bronson Jurko Gospodnetić Justyna Janczyszyn From 5d5f48097922dae26da06a12482a7a74de7ba924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=8E=AE?= Date: Mon, 18 Nov 2019 23:46:18 +0800 Subject: [PATCH 08/11] Hardening an existing test for demonstrating this change. --- testing/test_collection.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testing/test_collection.py b/testing/test_collection.py index 8050e80f9..fe5d66e94 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -685,6 +685,8 @@ class Test_genitems: def test_example_items1(self, testdir): p = testdir.makepyfile( """ + import pytest + def testone(): pass @@ -693,19 +695,24 @@ class Test_genitems: pass class TestY(TestX): - pass + @pytest.mark.parametrize("arg0", [".["]) + def testmethod_two(self, arg0): + pass """ ) items, reprec = testdir.inline_genitems(p) - assert len(items) == 3 + assert len(items) == 4 assert items[0].name == "testone" assert items[1].name == "testmethod_one" assert items[2].name == "testmethod_one" + assert items[3].name == "testmethod_two[.[]" # let's also test getmodpath here assert items[0].getmodpath() == "testone" assert items[1].getmodpath() == "TestX.testmethod_one" assert items[2].getmodpath() == "TestY.testmethod_one" + # PR #6202: Fix incorrect result of getmodpath method. (Resolves issue #6189) + assert items[3].getmodpath() == "TestY.testmethod_two[.[]" s = items[0].getmodpath(stopatmodule=False) assert s.endswith("test_example_items1.testone") From 63a23d876cad98d42f03cf6c6f397513e96ffcdb Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 18 Nov 2019 16:01:44 -0800 Subject: [PATCH 09/11] Remove check for os.symlink, always there in py3+ --- testing/acceptance_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ad9c37737..284796a42 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -754,7 +754,6 @@ class TestInvocationVariants: result = testdir.runpytest(str(p) + "::test", "--doctest-modules") result.stdout.fnmatch_lines(["*1 passed*"]) - @pytest.mark.skipif(not hasattr(os, "symlink"), reason="requires symlinks") def test_cmdline_python_package_symlink(self, testdir, monkeypatch): """ test --pyargs option with packages with path containing symlink can From 4b16b93cf57bb58d6dd55fb4b4ffa2a0a2a344db Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 19 Nov 2019 12:43:51 -0300 Subject: [PATCH 10/11] Preparing release version 5.3.0 --- CHANGELOG.rst | 202 ++++++++++++++++++++++++++++++ changelog/2049.bugfix.rst | 1 - changelog/2548.bugfix.rst | 1 - changelog/4488.feature.rst | 10 -- changelog/4730.feature.rst | 3 - changelog/4901.trivial.rst | 2 - changelog/5061.improvement.rst | 1 - changelog/5515.feature.rst | 11 -- changelog/5630.improvement.rst | 1 - changelog/5914.feature.rst | 19 --- changelog/5924.improvement.rst | 34 ----- changelog/5936.improvement.rst | 1 - changelog/5990.improvement.rst | 1 - changelog/6008.improvement.rst | 2 - changelog/6023.improvement.rst | 1 - changelog/6026.improvement.rst | 1 - changelog/6039.bugfix.rst | 3 - changelog/6047.bugfix.rst | 1 - changelog/6057.feature.rst | 3 - changelog/6059.improvement.rst | 1 - changelog/6061.feature.rst | 4 - changelog/6069.improvement.rst | 1 - changelog/6074.bugfix.rst | 1 - changelog/6097.improvement.rst | 1 - changelog/6116.improvement.rst | 1 - changelog/6148.improvement.rst | 1 - changelog/6152.improvement.rst | 1 - changelog/6176.improvement.rst | 1 - changelog/6179.deprecation.rst | 7 -- changelog/6181.improvement.rst | 1 - changelog/6189.bugfix.rst | 1 - changelog/6206.improvement.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-5.3.0.rst | 45 +++++++ doc/en/example/markers.rst | 2 +- doc/en/example/parametrize.rst | 9 +- doc/en/example/simple.rst | 2 +- doc/en/usage.rst | 4 +- doc/en/warnings.rst | 4 +- doc/en/writing_plugins.rst | 2 +- 40 files changed, 260 insertions(+), 129 deletions(-) delete mode 100644 changelog/2049.bugfix.rst delete mode 100644 changelog/2548.bugfix.rst delete mode 100644 changelog/4488.feature.rst delete mode 100644 changelog/4730.feature.rst delete mode 100644 changelog/4901.trivial.rst delete mode 100644 changelog/5061.improvement.rst delete mode 100644 changelog/5515.feature.rst delete mode 100644 changelog/5630.improvement.rst delete mode 100644 changelog/5914.feature.rst delete mode 100644 changelog/5924.improvement.rst delete mode 100644 changelog/5936.improvement.rst delete mode 100644 changelog/5990.improvement.rst delete mode 100644 changelog/6008.improvement.rst delete mode 100644 changelog/6023.improvement.rst delete mode 100644 changelog/6026.improvement.rst delete mode 100644 changelog/6039.bugfix.rst delete mode 100644 changelog/6047.bugfix.rst delete mode 100644 changelog/6057.feature.rst delete mode 100644 changelog/6059.improvement.rst delete mode 100644 changelog/6061.feature.rst delete mode 100644 changelog/6069.improvement.rst delete mode 100644 changelog/6074.bugfix.rst delete mode 100644 changelog/6097.improvement.rst delete mode 100644 changelog/6116.improvement.rst delete mode 100644 changelog/6148.improvement.rst delete mode 100644 changelog/6152.improvement.rst delete mode 100644 changelog/6176.improvement.rst delete mode 100644 changelog/6179.deprecation.rst delete mode 100644 changelog/6181.improvement.rst delete mode 100644 changelog/6189.bugfix.rst delete mode 100644 changelog/6206.improvement.rst create mode 100644 doc/en/announce/release-5.3.0.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e9ac09c8e..76b6caf1b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,208 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 5.3.0 (2019-11-19) +========================= + +Deprecations +------------ + +- `#6179 `_: The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given + that this is the version supported by default in modern tools that manipulate this type of file. + + In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option + is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``. + + For more information, `see the docs `__. + + + +Features +-------- + +- `#4488 `_: The pytest team has created the `pytest-reportlog `__ + plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes. + + Each line of the report log contains a self contained JSON object corresponding to a testing event, + such as a collection or a test result report. The file is guaranteed to be flushed after writing + each line, so systems can read and process events in real-time. + + The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed + in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and + provide feedback. + + +- `#4730 `_: When ``sys.pycache_prefix`` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism. + + This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions. + + +- `#5515 `_: Allow selective auto-indentation of multiline log messages. + + Adds command line option ``--log-auto-indent``, config option + ``log_auto_indent`` and support for per-entry configuration of + indentation behavior on calls to ``logging.log()``. + + Alters the default for auto-indention from ``on`` to ``off``. This + restores the older behavior that existed prior to v4.6.0. This + reversion to earlier behavior was done because it is better to + activate new features that may lead to broken tests explicitly + rather than implicitly. + + +- `#5914 `_: ``pytester`` learned two new functions, `no_fnmatch_line `_ and + `no_re_match_line `_. + + The functions are used to ensure the captured text *does not* match the given + pattern. + + The previous idiom was to use ``re.match``: + + .. code-block:: python + + assert re.match(pat, result.stdout.str()) is None + + Or the ``in`` operator: + + .. code-block:: python + + assert text in result.stdout.str() + + But the new functions produce best output on failure. + + +- `#6057 `_: Add tolerances to complex values when printing ``pytest.approx``. + + For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle. + + +- `#6061 `_: Adding the pluginmanager as an option ``pytest_addoption`` + so that hooks can be invoked when setting up command line options. This is + useful for having one plugin communicate things to another plugin, + such as default values or which set of command line options to add. + + + +Improvements +------------ + +- `#5061 `_: Use multiple colors with terminal summary statistics. + + +- `#5630 `_: Quitting from debuggers is now properly handled in ``doctest`` items. + + +- `#5924 `_: Improve verbose diff output with sequences. + + Before: + + .. code-block:: + + E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] + E Right contains 3 more items, first extra item: ' ' + E Full diff: + E - ['version', 'version_info', 'sys.version', 'sys.version_info'] + E + ['version', + E + 'version_info', + E + 'sys.version', + E + 'sys.version_info', + E + ' ', + E + 'sys.version', + E + 'sys.version_info'] + + After: + + .. code-block:: + + E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] + E Right contains 3 more items, first extra item: ' ' + E Full diff: + E [ + E 'version', + E 'version_info', + E 'sys.version', + E 'sys.version_info', + E + ' ', + E + 'sys.version', + E + 'sys.version_info', + E ] + + +- `#5936 `_: Display untruncated assertion message with ``-vv``. + + +- `#5990 `_: Fix plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors"). + + +- `#6008 `_: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be + immutable and avoid accidental modifications. + + +- `#6023 `_: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still). + + +- `#6026 `_: Align prefixes in output of pytester's ``LineMatcher``. + + +- `#6059 `_: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary. + + +- `#6069 `_: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally. + + +- `#6097 `_: The "[XXX%]" indicator in the test summary is colored according to the final (new) multi-colored line's main color. + + +- `#6116 `_: Add ``--co`` as a synonym to ``--collect-only``. + + +- `#6148 `_: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix. + + +- `#6152 `_: Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes. + + +- `#6176 `_: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``. + + +- `#6181 `_: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x`` gets reported. + + +- `#6206 `_: cacheprovider: improved robustness and performance with ``cache.set``. + + + +Bug Fixes +--------- + +- `#2049 `_: Fix ``-setup-plan`` showing inaccurate information about fixture lifetimes. + + +- `#2548 `_: Fix line offset mismatch with skipped tests in terminal summary. + + +- `#6039 `_: The ``PytestDoctestRunner`` is properly invalidated when unconfiguring the doctest plugin. + + This is important when used with ``pytester``'s ``runpytest_inprocess``. + + +- `#6047 `_: BaseExceptions are handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc. + + +- `#6074 `_: pytester: fix order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``. + + +- `#6189 `_: Fix incorrect result of ``getmodpath`` method. + + + +Trivial/Internal Changes +------------------------ + +- `#4901 `_: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a + valid ``pytest.ExitCode`` value. + + pytest 5.2.4 (2019-11-15) ========================= diff --git a/changelog/2049.bugfix.rst b/changelog/2049.bugfix.rst deleted file mode 100644 index 395396bd3..000000000 --- a/changelog/2049.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``-setup-plan`` showing inaccurate information about fixture lifetimes. diff --git a/changelog/2548.bugfix.rst b/changelog/2548.bugfix.rst deleted file mode 100644 index 8ee3b6462..000000000 --- a/changelog/2548.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix line offset mismatch with skipped tests in terminal summary. diff --git a/changelog/4488.feature.rst b/changelog/4488.feature.rst deleted file mode 100644 index 1e0387f44..000000000 --- a/changelog/4488.feature.rst +++ /dev/null @@ -1,10 +0,0 @@ -The pytest team has created the `pytest-reportlog `__ -plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes. - -Each line of the report log contains a self contained JSON object corresponding to a testing event, -such as a collection or a test result report. The file is guaranteed to be flushed after writing -each line, so systems can read and process events in real-time. - -The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed -in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and -provide feedback. diff --git a/changelog/4730.feature.rst b/changelog/4730.feature.rst deleted file mode 100644 index 80d1c4a38..000000000 --- a/changelog/4730.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -When ``sys.pycache_prefix`` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism. - -This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions. diff --git a/changelog/4901.trivial.rst b/changelog/4901.trivial.rst deleted file mode 100644 index f6609ddf1..000000000 --- a/changelog/4901.trivial.rst +++ /dev/null @@ -1,2 +0,0 @@ -``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a -valid ``pytest.ExitCode`` value. diff --git a/changelog/5061.improvement.rst b/changelog/5061.improvement.rst deleted file mode 100644 index 9eb0c1cd3..000000000 --- a/changelog/5061.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Use multiple colors with terminal summary statistics. diff --git a/changelog/5515.feature.rst b/changelog/5515.feature.rst deleted file mode 100644 index b53097c43..000000000 --- a/changelog/5515.feature.rst +++ /dev/null @@ -1,11 +0,0 @@ -Allow selective auto-indentation of multiline log messages. - -Adds command line option ``--log-auto-indent``, config option -``log_auto_indent`` and support for per-entry configuration of -indentation behavior on calls to ``logging.log()``. - -Alters the default for auto-indention from ``on`` to ``off``. This -restores the older behavior that existed prior to v4.6.0. This -reversion to earlier behavior was done because it is better to -activate new features that may lead to broken tests explicitly -rather than implicitly. diff --git a/changelog/5630.improvement.rst b/changelog/5630.improvement.rst deleted file mode 100644 index 45d49bdae..000000000 --- a/changelog/5630.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Quitting from debuggers is now properly handled in ``doctest`` items. diff --git a/changelog/5914.feature.rst b/changelog/5914.feature.rst deleted file mode 100644 index 68cd66f99..000000000 --- a/changelog/5914.feature.rst +++ /dev/null @@ -1,19 +0,0 @@ -``pytester`` learned two new functions, `no_fnmatch_line `_ and -`no_re_match_line `_. - -The functions are used to ensure the captured text *does not* match the given -pattern. - -The previous idiom was to use ``re.match``: - -.. code-block:: python - - assert re.match(pat, result.stdout.str()) is None - -Or the ``in`` operator: - -.. code-block:: python - - assert text in result.stdout.str() - -But the new functions produce best output on failure. diff --git a/changelog/5924.improvement.rst b/changelog/5924.improvement.rst deleted file mode 100644 index a03eb4704..000000000 --- a/changelog/5924.improvement.rst +++ /dev/null @@ -1,34 +0,0 @@ -Improve verbose diff output with sequences. - -Before: - -.. code-block:: - - E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] - E Right contains 3 more items, first extra item: ' ' - E Full diff: - E - ['version', 'version_info', 'sys.version', 'sys.version_info'] - E + ['version', - E + 'version_info', - E + 'sys.version', - E + 'sys.version_info', - E + ' ', - E + 'sys.version', - E + 'sys.version_info'] - -After: - -.. code-block:: - - E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] - E Right contains 3 more items, first extra item: ' ' - E Full diff: - E [ - E 'version', - E 'version_info', - E 'sys.version', - E 'sys.version_info', - E + ' ', - E + 'sys.version', - E + 'sys.version_info', - E ] diff --git a/changelog/5936.improvement.rst b/changelog/5936.improvement.rst deleted file mode 100644 index c5cd924bb..000000000 --- a/changelog/5936.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Display untruncated assertion message with ``-vv``. diff --git a/changelog/5990.improvement.rst b/changelog/5990.improvement.rst deleted file mode 100644 index 6f5ad648e..000000000 --- a/changelog/5990.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Fix plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors"). diff --git a/changelog/6008.improvement.rst b/changelog/6008.improvement.rst deleted file mode 100644 index 22ef35cc8..000000000 --- a/changelog/6008.improvement.rst +++ /dev/null @@ -1,2 +0,0 @@ -``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be -immutable and avoid accidental modifications. diff --git a/changelog/6023.improvement.rst b/changelog/6023.improvement.rst deleted file mode 100644 index 6cf81002e..000000000 --- a/changelog/6023.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still). diff --git a/changelog/6026.improvement.rst b/changelog/6026.improvement.rst deleted file mode 100644 index 34dfb278d..000000000 --- a/changelog/6026.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Align prefixes in output of pytester's ``LineMatcher``. diff --git a/changelog/6039.bugfix.rst b/changelog/6039.bugfix.rst deleted file mode 100644 index b13a677c8..000000000 --- a/changelog/6039.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -The ``PytestDoctestRunner`` is properly invalidated when unconfiguring the doctest plugin. - -This is important when used with ``pytester``'s ``runpytest_inprocess``. diff --git a/changelog/6047.bugfix.rst b/changelog/6047.bugfix.rst deleted file mode 100644 index 11a997f71..000000000 --- a/changelog/6047.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -BaseExceptions are handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc. diff --git a/changelog/6057.feature.rst b/changelog/6057.feature.rst deleted file mode 100644 index b7334e7fe..000000000 --- a/changelog/6057.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add tolerances to complex values when printing ``pytest.approx``. - -For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle. diff --git a/changelog/6059.improvement.rst b/changelog/6059.improvement.rst deleted file mode 100644 index 39ffff99b..000000000 --- a/changelog/6059.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Collection errors are reported as errors (and not failures like before) in the terminal's short test summary. diff --git a/changelog/6061.feature.rst b/changelog/6061.feature.rst deleted file mode 100644 index 11f548625..000000000 --- a/changelog/6061.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -Adding the pluginmanager as an option ``pytest_addoption`` -so that hooks can be invoked when setting up command line options. This is -useful for having one plugin communicate things to another plugin, -such as default values or which set of command line options to add. diff --git a/changelog/6069.improvement.rst b/changelog/6069.improvement.rst deleted file mode 100644 index e60d154bb..000000000 --- a/changelog/6069.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally. diff --git a/changelog/6074.bugfix.rst b/changelog/6074.bugfix.rst deleted file mode 100644 index 624cf5d1c..000000000 --- a/changelog/6074.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -pytester: fix order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``. diff --git a/changelog/6097.improvement.rst b/changelog/6097.improvement.rst deleted file mode 100644 index 32eb84906..000000000 --- a/changelog/6097.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -The "[XXX%]" indicator in the test summary is colored according to the final (new) multi-colored line's main color. diff --git a/changelog/6116.improvement.rst b/changelog/6116.improvement.rst deleted file mode 100644 index 4fc96ec77..000000000 --- a/changelog/6116.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Add ``--co`` as a synonym to ``--collect-only``. diff --git a/changelog/6148.improvement.rst b/changelog/6148.improvement.rst deleted file mode 100644 index 3d77ab528..000000000 --- a/changelog/6148.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix. diff --git a/changelog/6152.improvement.rst b/changelog/6152.improvement.rst deleted file mode 100644 index 8e5f4d52a..000000000 --- a/changelog/6152.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes. diff --git a/changelog/6176.improvement.rst b/changelog/6176.improvement.rst deleted file mode 100644 index 39787da2e..000000000 --- a/changelog/6176.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``. diff --git a/changelog/6179.deprecation.rst b/changelog/6179.deprecation.rst deleted file mode 100644 index 97f7ec74b..000000000 --- a/changelog/6179.deprecation.rst +++ /dev/null @@ -1,7 +0,0 @@ -The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given -that this is the version supported by default in modern tools that manipulate this type of file. - -In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option -is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``. - -For more information, `see the docs `__. diff --git a/changelog/6181.improvement.rst b/changelog/6181.improvement.rst deleted file mode 100644 index 0960f6203..000000000 --- a/changelog/6181.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -The reason for a stopped session, e.g. with ``--maxfail`` / ``-x`` gets reported. diff --git a/changelog/6189.bugfix.rst b/changelog/6189.bugfix.rst deleted file mode 100644 index 060a2260a..000000000 --- a/changelog/6189.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix incorrect result of ``getmodpath`` method. diff --git a/changelog/6206.improvement.rst b/changelog/6206.improvement.rst deleted file mode 100644 index 67d8363b3..000000000 --- a/changelog/6206.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -cacheprovider: improved robustness and performance with ``cache.set``. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index e7c011411..6e6914f2d 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-5.3.0 release-5.2.4 release-5.2.3 release-5.2.2 diff --git a/doc/en/announce/release-5.3.0.rst b/doc/en/announce/release-5.3.0.rst new file mode 100644 index 000000000..9855a7a2d --- /dev/null +++ b/doc/en/announce/release-5.3.0.rst @@ -0,0 +1,45 @@ +pytest-5.3.0 +======================================= + +The pytest team is proud to announce the 5.3.0 release! + +pytest is a mature Python testing tool with more than a 2000 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: + + https://docs.pytest.org/en/latest/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/latest/ + +As usual, you can upgrade from pypi via: + + pip install -U pytest + +Thanks to all who contributed to this release, among them: + +* AnjoMan +* Anthony Sottile +* Anton Lodder +* Bruno Oliveira +* Daniel Hahler +* Gregory Lee +* Josh Karpel +* JoshKarpel +* Joshua Storck +* Kale Kundert +* MarcoGorelli +* Michael Krebs +* NNRepos +* Ran Benita +* TH3CHARLie +* Tibor Arpas +* Zac Hatfield-Dodds +* 林玮 + + +Happy testing, +The Pytest Development Team diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index ccddb1f66..8143b3fd4 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -622,7 +622,7 @@ then you will see two tests skipped and two executed tests as expected: test_plat.py s.s. [100%] ========================= short test summary info ========================== - SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:13: cannot run on platform linux + SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux ======================= 2 passed, 2 skipped in 0.12s ======================= Note that if you specify a platform via the marker-command line option like this: diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 0e131dace..c420761a4 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -475,10 +475,11 @@ Running it results in some skips if we don't have all the python interpreters in .. code-block:: pytest . $ pytest -rs -q multipython.py - ssssssssssss......sss...... [100%] + ssssssssssss...ssssssssssss [100%] ========================= short test summary info ========================== - SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found - 12 passed, 15 skipped in 0.12s + SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.5' not found + SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.7' not found + 3 passed, 24 skipped in 0.12s Indirect parametrization of optional implementations/imports -------------------------------------------------------------------- @@ -546,7 +547,7 @@ If you run this with reporting for skips enabled: test_module.py .s [100%] ========================= short test summary info ========================== - SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:13: could not import 'opt2': No module named 'opt2' + SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:12: could not import 'opt2': No module named 'opt2' ======================= 1 passed, 1 skipped in 0.12s ======================= You'll see that we don't have an ``opt2`` module and thus the second test run diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 05ccbc9b2..1570850fc 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -443,7 +443,7 @@ Now we can profile which test functions execute the slowest: ========================= slowest 3 test durations ========================= 0.30s call test_some_are_slow.py::test_funcslow2 0.20s call test_some_are_slow.py::test_funcslow1 - 0.10s call test_some_are_slow.py::test_funcfast + 0.11s call test_some_are_slow.py::test_funcfast ============================ 3 passed in 0.12s ============================= incremental testing - test steps diff --git a/doc/en/usage.rst b/doc/en/usage.rst index ea849c1a7..245a67b68 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -241,7 +241,7 @@ Example: test_example.py:14: AssertionError ========================= short test summary info ========================== - SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test + SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test XFAIL test_example.py::test_xfail reason: xfailing this test XPASS test_example.py::test_xpass always xfail @@ -296,7 +296,7 @@ More than one character can be used, so for example to only see failed and skipp test_example.py:14: AssertionError ========================= short test summary info ========================== FAILED test_example.py::test_fail - assert 0 - SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test + SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s === Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 54bb60da1..4b8be4469 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -41,7 +41,7 @@ Running pytest now produces this output: warnings.warn(UserWarning("api v1, should use functions from v2")) -- Docs: https://docs.pytest.org/en/latest/warnings.html - ====================== 1 passed, 1 warnings in 0.12s ======================= + ======================= 1 passed, 1 warning in 0.12s ======================= The ``-W`` flag can be passed to control which warnings will be displayed or even turn them into errors: @@ -407,7 +407,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta class Test: -- Docs: https://docs.pytest.org/en/latest/warnings.html - 1 warnings in 0.12s + 1 warning in 0.12s These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings. diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index 8660746bd..2f7283791 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -442,7 +442,7 @@ additionally it is possible to copy examples for an example folder before runnin testdir.copy_example("test_example.py") -- Docs: https://docs.pytest.org/en/latest/warnings.html - ====================== 2 passed, 1 warnings in 0.12s ======================= + ======================= 2 passed, 1 warning in 0.12s ======================= For more information about the result object that ``runpytest()`` returns, and the methods that it provides please check out the :py:class:`RunResult From be59827216612fd416818702be7e2b8448f4089d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 19 Nov 2019 13:56:22 -0300 Subject: [PATCH 11/11] Small fixes in the CHANGELOG for 5.3.0 --- CHANGELOG.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 76b6caf1b..a63e6f838 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -88,12 +88,12 @@ Features But the new functions produce best output on failure. -- `#6057 `_: Add tolerances to complex values when printing ``pytest.approx``. +- `#6057 `_: Added tolerances to complex values when printing ``pytest.approx``. For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle. -- `#6061 `_: Adding the pluginmanager as an option ``pytest_addoption`` +- `#6061 `_: Added the pluginmanager as an argument to ``pytest_addoption`` so that hooks can be invoked when setting up command line options. This is useful for having one plugin communicate things to another plugin, such as default values or which set of command line options to add. @@ -109,7 +109,7 @@ Improvements - `#5630 `_: Quitting from debuggers is now properly handled in ``doctest`` items. -- `#5924 `_: Improve verbose diff output with sequences. +- `#5924 `_: Improved verbose diff output with sequences. Before: @@ -148,14 +148,14 @@ Improvements - `#5936 `_: Display untruncated assertion message with ``-vv``. -- `#5990 `_: Fix plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors"). +- `#5990 `_: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors"). - `#6008 `_: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be immutable and avoid accidental modifications. -- `#6023 `_: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still). +- `#6023 `_: ``pytest.main`` now returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still). - `#6026 `_: Align prefixes in output of pytester's ``LineMatcher``. @@ -167,10 +167,10 @@ Improvements - `#6069 `_: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally. -- `#6097 `_: The "[XXX%]" indicator in the test summary is colored according to the final (new) multi-colored line's main color. +- `#6097 `_: The "[XXX%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color. -- `#6116 `_: Add ``--co`` as a synonym to ``--collect-only``. +- `#6116 `_: Added ``--co`` as a synonym to ``--collect-only``. - `#6148 `_: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix. @@ -182,34 +182,34 @@ Improvements - `#6176 `_: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``. -- `#6181 `_: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x`` gets reported. +- `#6181 `_: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary. -- `#6206 `_: cacheprovider: improved robustness and performance with ``cache.set``. +- `#6206 `_: Improved ``cache.set`` robustness and performance. Bug Fixes --------- -- `#2049 `_: Fix ``-setup-plan`` showing inaccurate information about fixture lifetimes. +- `#2049 `_: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes. -- `#2548 `_: Fix line offset mismatch with skipped tests in terminal summary. +- `#2548 `_: Fixed line offset mismatch of skipped tests in terminal summary. -- `#6039 `_: The ``PytestDoctestRunner`` is properly invalidated when unconfiguring the doctest plugin. +- `#6039 `_: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin. This is important when used with ``pytester``'s ``runpytest_inprocess``. -- `#6047 `_: BaseExceptions are handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc. +- `#6047 `_: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc. -- `#6074 `_: pytester: fix order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``. +- `#6074 `_: pytester: fixed order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``. -- `#6189 `_: Fix incorrect result of ``getmodpath`` method. +- `#6189 `_: Fixed result of ``getmodpath`` method.