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] 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`: 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 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/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/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) 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() 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):