From 7ccfc39f1526e7789799d3e9b6b736cc2b9bfd20 Mon Sep 17 00:00:00 2001 From: William Jamir Silva Date: Mon, 5 Oct 2020 14:04:37 -0300 Subject: [PATCH 1/6] Update reference.rst informing the default junit_family (#7860) Co-authored-by: Bruno Oliveira --- doc/en/reference.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/en/reference.rst b/doc/en/reference.rst index d1540a8ff2a..15d8250844f 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -1236,12 +1236,13 @@ passed multiple times. The expected format is ``name=value``. For example:: .. confval:: junit_family .. versionadded:: 4.2 + .. versionchanged:: 6.1 + Default changed to ``xunit2``. Configures the format of the generated JUnit XML file. The possible options are: - * ``xunit1`` (or ``legacy``): produces old style output, compatible with the xunit 1.0 format. **This is the default**. - * ``xunit2``: produces `xunit 2.0 style output `__, - which should be more compatible with latest Jenkins versions. + * ``xunit1`` (or ``legacy``): produces old style output, compatible with the xunit 1.0 format. + * ``xunit2``: produces `xunit 2.0 style output `__, which should be more compatible with latest Jenkins versions. **This is the default**. .. code-block:: ini From c93962c49123928650cc1e18d172e10194fecebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Mari=C3=B1ez?= Date: Tue, 6 Oct 2020 10:48:34 -0400 Subject: [PATCH 2/6] Add alias clarification to deprecation warning (#7829) Co-authored-by: Bruno Oliveira --- changelog/7815.doc.rst | 1 + src/_pytest/deprecated.py | 7 ++++--- src/_pytest/fixtures.py | 17 +++++++++++++++-- src/pytest/__init__.py | 2 +- testing/deprecated_test.py | 19 ++++++++++++++++++- testing/python/fixtures.py | 2 +- 6 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 changelog/7815.doc.rst diff --git a/changelog/7815.doc.rst b/changelog/7815.doc.rst new file mode 100644 index 00000000000..d799bb42500 --- /dev/null +++ b/changelog/7815.doc.rst @@ -0,0 +1 @@ +Improve deprecation warning message for ``pytest._fillfuncargs()``. diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index ecdb60d37f5..fd00fe2d6d5 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -20,9 +20,10 @@ } -FILLFUNCARGS = PytestDeprecationWarning( - "The `_fillfuncargs` function is deprecated, use " - "function._request._fillfixtures() instead if you cannot avoid reaching into internals." +FILLFUNCARGS = UnformattedWarning( + PytestDeprecationWarning, + "{name} is deprecated, use " + "function._request._fillfixtures() instead if you cannot avoid reaching into internals.", ) PYTEST_COLLECT_MODULE = UnformattedWarning( diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index f526f484b29..a299b2dba50 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -339,9 +339,22 @@ def reorder_items_atscope( return items_done +def _fillfuncargs(function: "Function") -> None: + """Fill missing fixtures for a test function, old public API (deprecated).""" + warnings.warn(FILLFUNCARGS.format(name="pytest._fillfuncargs()"), stacklevel=2) + _fill_fixtures_impl(function) + + def fillfixtures(function: "Function") -> None: - """Fill missing funcargs for a test function.""" - warnings.warn(FILLFUNCARGS, stacklevel=2) + """Fill missing fixtures for a test function (deprecated).""" + warnings.warn( + FILLFUNCARGS.format(name="_pytest.fixtures.fillfixtures()"), stacklevel=2 + ) + _fill_fixtures_impl(function) + + +def _fill_fixtures_impl(function: "Function") -> None: + """Internal implementation to fill fixtures on the given function object.""" try: request = function._request except AttributeError: diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index c4c28191877..a9c1ee0282b 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -11,7 +11,7 @@ from _pytest.config import main from _pytest.config import UsageError from _pytest.debugging import pytestPDB as __pytestPDB -from _pytest.fixtures import fillfixtures as _fillfuncargs +from _pytest.fixtures import _fillfuncargs from _pytest.fixtures import fixture from _pytest.fixtures import FixtureLookupError from _pytest.fixtures import yield_fixture diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index eb5d527f52b..5fe9ad7305f 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -1,3 +1,4 @@ +import re import warnings from unittest import mock @@ -26,11 +27,27 @@ def test_external_plugins_integrated(testdir, plugin): def test_fillfuncargs_is_deprecated() -> None: with pytest.warns( pytest.PytestDeprecationWarning, - match="The `_fillfuncargs` function is deprecated", + match=re.escape( + "pytest._fillfuncargs() is deprecated, use " + "function._request._fillfixtures() instead if you cannot avoid reaching into internals." + ), ): pytest._fillfuncargs(mock.Mock()) +def test_fillfixtures_is_deprecated() -> None: + import _pytest.fixtures + + with pytest.warns( + pytest.PytestDeprecationWarning, + match=re.escape( + "_pytest.fixtures.fillfixtures() is deprecated, use " + "function._request._fillfixtures() instead if you cannot avoid reaching into internals." + ), + ): + _pytest.fixtures.fillfixtures(mock.Mock()) + + def test_minus_k_dash_is_deprecated(testdir) -> None: threepass = testdir.makepyfile( test_threepass=""" diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 9ae5a91db43..67b7ad60116 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -87,7 +87,7 @@ class T: class TestFillFixtures: def test_fillfuncargs_exposed(self): # used by oejskit, kept for compatibility - assert pytest._fillfuncargs == fixtures.fillfixtures + assert pytest._fillfuncargs == fixtures._fillfuncargs def test_funcarg_lookupfails(self, testdir): testdir.copy_example() From 9237b5f6335af39377a231d26648b48bab3eb871 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 21 Oct 2020 10:12:32 +0300 Subject: [PATCH 3/6] Merge pull request #7915 from bluetech/fix-lf-package cacheprovider: fix some files in packages getting lost from --lf (cherry picked from commit a66b6b857a39b7cbdd449dded07c64dac49f42a8) with some needed adjustments to 6.1.x. --- changelog/7758.bugfix.rst | 1 + src/_pytest/cacheprovider.py | 6 +++++- testing/test_cacheprovider.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 changelog/7758.bugfix.rst diff --git a/changelog/7758.bugfix.rst b/changelog/7758.bugfix.rst new file mode 100644 index 00000000000..a3119b46c0d --- /dev/null +++ b/changelog/7758.bugfix.rst @@ -0,0 +1 @@ +Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0. diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index b04305ed9d2..e7c96ba3647 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -29,6 +29,7 @@ from _pytest.fixtures import FixtureRequest from _pytest.main import Session from _pytest.python import Module +from _pytest.python import Package from _pytest.reports import TestReport @@ -233,7 +234,10 @@ def __init__(self, lfplugin: "LFPlugin") -> None: def pytest_make_collect_report( self, collector: nodes.Collector ) -> Optional[CollectReport]: - if isinstance(collector, Module): + # Packages are Modules, but _last_failed_paths only contains + # test-bearing paths and doesn't try to include the paths of their + # packages, so don't filter them. + if isinstance(collector, Module) and not isinstance(collector, Package): if Path(str(collector.fspath)) not in self.lfplugin._last_failed_paths: self.lfplugin._skipped_files += 1 diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index a911257ce24..57b245c7d5c 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -984,6 +984,36 @@ def test_pass(): pass ) assert result.ret == 0 + def test_packages(self, testdir: Testdir) -> None: + """Regression test for #7758. + + The particular issue here was that Package nodes were included in the + filtering, being themselves Modules for the __init__.py, even if they + had failed Modules in them. + + The tests includes a test in an __init__.py file just to make sure the + fix doesn't somehow regress that, it is not critical for the issue. + """ + testdir.makepyfile( + **{ + "__init__.py": "", + "a/__init__.py": "def test_a_init(): assert False", + "a/test_one.py": "def test_1(): assert False", + "b/__init__.py": "", + "b/test_two.py": "def test_2(): assert False", + }, + ) + testdir.makeini( + """ + [pytest] + python_files = *.py + """ + ) + result = testdir.runpytest() + result.assert_outcomes(failed=3) + result = testdir.runpytest("--lf") + result.assert_outcomes(failed=3) + class TestNewFirst: def test_newfirst_usecase(self, testdir): From cd57271455e56661f2931bcb6cc05e9f7e87f4b0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Oct 2020 08:02:30 -0300 Subject: [PATCH 4/6] Merge pull request #7917 from bluetech/ci-timeout ci: decrease job timeout from 6 hours to 30 minutes --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ef1a08b993..106e41bf215 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ on: jobs: build: runs-on: ${{ matrix.os }} + timeout-minutes: 30 strategy: fail-fast: false @@ -187,6 +188,7 @@ jobs: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest' runs-on: ubuntu-latest + timeout-minutes: 30 needs: [build] From 8c1c1ae3107b890e53d8396cfbf79a5a20af09db Mon Sep 17 00:00:00 2001 From: Vasilis Gerakaris Date: Wed, 28 Oct 2020 13:23:35 +0200 Subject: [PATCH 5/6] Increase temp dir deletion period to 3 days (#7914) Co-authored-by: Bruno Oliveira --- changelog/7911.bugfix.rst | 1 + src/_pytest/pathlib.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/7911.bugfix.rst diff --git a/changelog/7911.bugfix.rst b/changelog/7911.bugfix.rst new file mode 100644 index 00000000000..5b85b20b5bc --- /dev/null +++ b/changelog/7911.bugfix.rst @@ -0,0 +1 @@ +Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites. diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 355281039fd..dda86d6beba 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -38,7 +38,7 @@ __all__ = ["Path", "PurePath"] -LOCK_TIMEOUT = 60 * 60 * 3 +LOCK_TIMEOUT = 60 * 60 * 24 * 3 _AnyPurePath = TypeVar("_AnyPurePath", bound=PurePath) From 4e8b50ba01f0d8a6a2abb98440d3421a037eddb7 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Wed, 28 Oct 2020 11:37:31 +0000 Subject: [PATCH 6/6] Prepare release version 6.1.2 --- changelog/7758.bugfix.rst | 1 - changelog/7815.doc.rst | 1 - changelog/7911.bugfix.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-6.1.2.rst | 22 ++++++++++++++++++++++ doc/en/changelog.rst | 19 +++++++++++++++++++ doc/en/getting-started.rst | 2 +- 7 files changed, 43 insertions(+), 4 deletions(-) delete mode 100644 changelog/7758.bugfix.rst delete mode 100644 changelog/7815.doc.rst delete mode 100644 changelog/7911.bugfix.rst create mode 100644 doc/en/announce/release-6.1.2.rst diff --git a/changelog/7758.bugfix.rst b/changelog/7758.bugfix.rst deleted file mode 100644 index a3119b46c0d..00000000000 --- a/changelog/7758.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0. diff --git a/changelog/7815.doc.rst b/changelog/7815.doc.rst deleted file mode 100644 index d799bb42500..00000000000 --- a/changelog/7815.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Improve deprecation warning message for ``pytest._fillfuncargs()``. diff --git a/changelog/7911.bugfix.rst b/changelog/7911.bugfix.rst deleted file mode 100644 index 5b85b20b5bc..00000000000 --- a/changelog/7911.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index bda389cd8be..f0e44107b69 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-6.1.2 release-6.1.1 release-6.1.0 release-6.0.2 diff --git a/doc/en/announce/release-6.1.2.rst b/doc/en/announce/release-6.1.2.rst new file mode 100644 index 00000000000..aa2c8095205 --- /dev/null +++ b/doc/en/announce/release-6.1.2.rst @@ -0,0 +1,22 @@ +pytest-6.1.2 +======================================= + +pytest 6.1.2 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Bruno Oliveira +* Manuel MariƱez +* Ran Benita +* Vasilis Gerakaris +* William Jamir Silva + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 2a26b5c3fb9..8897ece8cb8 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -28,6 +28,25 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 6.1.2 (2020-10-28) +========================= + +Bug Fixes +--------- + +- `#7758 `_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0. + + +- `#7911 `_: Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites. + + + +Improved Documentation +---------------------- + +- `#7815 `_: Improve deprecation warning message for ``pytest._fillfuncargs()``. + + pytest 6.1.1 (2020-10-03) ========================= diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 5a5f0fa7a43..3e4cdaf7220 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -28,7 +28,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 6.1.1 + pytest 6.1.2 .. _`simpletest`: