From d42f5a41a5ad3ba0888286b38deb4064167fa4a2 Mon Sep 17 00:00:00 2001 From: marc Date: Sat, 14 Dec 2019 19:52:17 +0100 Subject: [PATCH 01/22] delete inspect.getargspect() as is deprecated since Python 3.0 --- testing/test_runner.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/testing/test_runner.py b/testing/test_runner.py index 301e11898..df0b7b0cf 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -468,10 +468,7 @@ reporttypes = [reports.BaseReport, reports.TestReport, reports.CollectReport] "reporttype", reporttypes, ids=[x.__name__ for x in reporttypes] ) def test_report_extra_parameters(reporttype): - if hasattr(inspect, "signature"): - args = list(inspect.signature(reporttype.__init__).parameters.keys())[1:] - else: - args = inspect.getargspec(reporttype.__init__)[0][1:] + args = list(inspect.signature(reporttype.__init__).parameters.keys())[1:] basekw = dict.fromkeys(args, []) report = reporttype(newthing=1, **basekw) assert report.newthing == 1 From d4879c7afbf17192565926c3acb7dd633fd588f2 Mon Sep 17 00:00:00 2001 From: Seth Junot Date: Sun, 15 Dec 2019 18:58:08 -0800 Subject: [PATCH 02/22] Optimized renaming of test parameter ids While using pytest-repeat, I noticed the previous implementation is slow for a large number of duplicate test ids. To optimize, this commit reduces the amount of data copied and avoids using `in` with List (unhashable type, and therefore is very slow for many elements). --- AUTHORS | 1 + changelog/6350.trivial.rst | 1 + src/_pytest/python.py | 26 ++++++++++++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 changelog/6350.trivial.rst diff --git a/AUTHORS b/AUTHORS index cc9b14be3..6288f8c1b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -235,6 +235,7 @@ Samuele Pedroni Sankt Petersbug Segev Finer Serhii Mozghovyi +Seth Junot Simon Gomizelj Skylar Downes Srinivas Reddy Thatiparthy diff --git a/changelog/6350.trivial.rst b/changelog/6350.trivial.rst new file mode 100644 index 000000000..c43fb4267 --- /dev/null +++ b/changelog/6350.trivial.rst @@ -0,0 +1 @@ +Optimized automatic renaming of test parameter IDs. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index d787638c9..bc35ccf5f 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -6,6 +6,7 @@ import os import sys import warnings from collections import Counter +from collections import defaultdict from collections.abc import Sequence from functools import partial from textwrap import dedent @@ -1190,14 +1191,23 @@ def idmaker(argnames, parametersets, idfn=None, ids=None, config=None, item=None _idvalset(valindex, parameterset, argnames, idfn, ids, config=config, item=item) for valindex, parameterset in enumerate(parametersets) ] - if len(set(ids)) != len(ids): - # The ids are not unique - duplicates = [testid for testid in ids if ids.count(testid) > 1] - counters = Counter() - for index, testid in enumerate(ids): - if testid in duplicates: - ids[index] = testid + str(counters[testid]) - counters[testid] += 1 + + # All IDs must be unique! + unique_ids = set(ids) + if len(unique_ids) != len(ids): + + # Record the number of occurrences of each test ID + test_id_counts = Counter(ids) + + # Map the test ID to its next suffix + test_id_suffixes = defaultdict(int) + + # Suffix non-unique IDs to make them unique + for index, test_id in enumerate(ids): + if test_id_counts[test_id] > 1: + ids[index] = "{}{}".format(test_id, test_id_suffixes[test_id]) + test_id_suffixes[test_id] += 1 + return ids From dc7bf518b33b97b08ce54e3ae061c200181757d3 Mon Sep 17 00:00:00 2001 From: Alexandre Mulatinho Date: Wed, 18 Dec 2019 15:15:53 -0300 Subject: [PATCH 03/22] pytester: quick fix error introduced in #5990 - added a test to check this condition Signed-off-by: Alexandre Mulatinho --- changelog/6532.bugfix.rst | 1 + src/_pytest/pytester.py | 2 +- testing/test_pytester.py | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelog/6532.bugfix.rst diff --git a/changelog/6532.bugfix.rst b/changelog/6532.bugfix.rst new file mode 100644 index 000000000..dbfa0534d --- /dev/null +++ b/changelog/6532.bugfix.rst @@ -0,0 +1 @@ +Fix problem with ``testdir`` not recognizing errors correctly in runs with a single test. diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index f44a69a95..490649ad7 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -456,7 +456,7 @@ class RunResult: "passed": d.get("passed", 0), "skipped": d.get("skipped", 0), "failed": d.get("failed", 0), - "error": d.get("error", 0), + "error": d.get("error", 0) + d.get("errors", 0), "xpassed": d.get("xpassed", 0), "xfailed": d.get("xfailed", 0), } diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 5bdbacdd0..fe0002b64 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -682,3 +682,23 @@ def test_run_result_repr(): repr(r) == "" ) + + +def test_run_pytester_with_single_test(testdir): + testcode = """ + import pytest + + @pytest.fixture + def bad_fixture(): + raise Exception("bad") + + def test_error1(bad_fixture): + pass + + def test_error2(bad_fixture): + pass + """ + + testdir.makepyfile(testcode) + result = testdir.runpytest() + result.assert_outcomes(error=2) From 536177bb56a500e23bf438b93d6760f8479df134 Mon Sep 17 00:00:00 2001 From: marc Date: Thu, 19 Dec 2019 10:35:15 +0100 Subject: [PATCH 04/22] fix typos in docs --- README.rst | 2 +- doc/en/announce/release-2.3.0.rst | 4 ++-- doc/en/announce/release-2.5.0.rst | 2 +- doc/en/announce/release-2.7.0.rst | 2 +- doc/en/changelog.rst | 6 +++--- doc/en/historical-notes.rst | 2 +- doc/en/index.rst | 2 +- doc/en/py27-py34-deprecation.rst | 2 +- doc/en/sponsor.rst | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 53e643a5b..15ab4f0bc 100644 --- a/README.rst +++ b/README.rst @@ -117,7 +117,7 @@ It provide tools to raise money and share your finances in full transparency. It is the platform of choice for individuals and companies that want to make one-time or monthly donations directly to the project. -See more datails in the `pytest collective`_. +See more details in the `pytest collective`_. .. _Open Collective: https://opencollective.com .. _pytest collective: https://opencollective.com/pytest diff --git a/doc/en/announce/release-2.3.0.rst b/doc/en/announce/release-2.3.0.rst index 5fb253670..1b9d0dcc1 100644 --- a/doc/en/announce/release-2.3.0.rst +++ b/doc/en/announce/release-2.3.0.rst @@ -3,13 +3,13 @@ pytest-2.3: improved fixtures / better unittest integration pytest-2.3 comes with many major improvements for fixture/funcarg management and parametrized testing in Python. It is now easier, more efficient and -more predicatable to re-run the same tests with different fixture +more predictable to re-run the same tests with different fixture instances. Also, you can directly declare the caching "scope" of fixtures so that dependent tests throughout your whole test suite can re-use database or other expensive fixture objects with ease. Lastly, it's possible for fixture functions (formerly known as funcarg factories) to use other fixtures, allowing for a completely modular and -re-useable fixture design. +re-usable fixture design. For detailed info and tutorial-style examples, see: diff --git a/doc/en/announce/release-2.5.0.rst b/doc/en/announce/release-2.5.0.rst index 29064e05e..bc83fdc12 100644 --- a/doc/en/announce/release-2.5.0.rst +++ b/doc/en/announce/release-2.5.0.rst @@ -91,7 +91,7 @@ holger krekel it might be the cause for other finalizers to fail. - fix ordering when mock.patch or other standard decorator-wrappings - are used with test methods. This fixues issue346 and should + are used with test methods. This fixes issue346 and should help with random "xdist" collection failures. Thanks to Ronny Pfannschmidt and Donald Stufft for helping to isolate it. diff --git a/doc/en/announce/release-2.7.0.rst b/doc/en/announce/release-2.7.0.rst index 8952ff50f..cf798ff2c 100644 --- a/doc/en/announce/release-2.7.0.rst +++ b/doc/en/announce/release-2.7.0.rst @@ -35,7 +35,7 @@ holger krekel - fix issue435: make reload() work when assert rewriting is active. Thanks Daniel Hahler. -- fix issue616: conftest.py files and their contained fixutres are now +- fix issue616: conftest.py files and their contained fixtures are now properly considered for visibility, independently from the exact current working directory and test arguments that are used. Many thanks to Eric Siegerman and his PR235 which contains diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 46fa240e0..88f07ba69 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -5343,7 +5343,7 @@ time or change existing behaviors in order to make them less surprising/more use Thanks Ronny Pfannschmidt for most of the merging work. - "-r" option now accepts "a" to include all possible reports, similar - to passing "fEsxXw" explicitly (isse960). + to passing "fEsxXw" explicitly (issue960). Thanks Abhijeet Kasurde for the PR. - avoid python3.5 deprecation warnings by introducing version @@ -5633,7 +5633,7 @@ time or change existing behaviors in order to make them less surprising/more use - fix issue435: make reload() work when assert rewriting is active. Thanks Daniel Hahler. -- fix issue616: conftest.py files and their contained fixutres are now +- fix issue616: conftest.py files and their contained fixtures are now properly considered for visibility, independently from the exact current working directory and test arguments that are used. Many thanks to Eric Siegerman and his PR235 which contains @@ -7180,7 +7180,7 @@ Bug fixes: - streamlined plugin loading: order is now as documented in customize.html: setuptools, ENV, commandline, conftest. - also setuptools entry point names are turned to canonical namees ("pytest_*") + also setuptools entry point names are turned to canonical names ("pytest_*") - automatically skip tests that need 'capfd' but have no os.dup diff --git a/doc/en/historical-notes.rst b/doc/en/historical-notes.rst index c8403728f..ba96d32ab 100644 --- a/doc/en/historical-notes.rst +++ b/doc/en/historical-notes.rst @@ -111,7 +111,7 @@ More details can be found in the `original PR `__. +The technical aspects of the Python 2.7 and 3.4 support plan (such as when releases will occur, how to backport fixes, etc) is described in issue `#5275 `__. diff --git a/doc/en/sponsor.rst b/doc/en/sponsor.rst index 1023928b3..8362a7f0a 100644 --- a/doc/en/sponsor.rst +++ b/doc/en/sponsor.rst @@ -17,7 +17,7 @@ It provide tools to raise money and share your finances in full transparency. It is the platform of choice for individuals and companies that want to make one-time or monthly donations directly to the project. -See more datails in the `pytest collective`_. +See more details in the `pytest collective`_. .. _Tidelift: https://tidelift.com From d76aa8b428f605e9050b44d6879c6645f1421047 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 18 Dec 2019 17:56:33 -0300 Subject: [PATCH 05/22] Add GitHub actions for CI This includes our current full matrix (windows, linux and macos), for evaluting purposes. We should disconsider failures when evaluating PRs. TODO: - deploy - coverage - github release notes Even with the above missing, I still believe it would be nice to merge this and have GitHub actions working in parallel so we can evaluate performance and usability from now on. --- .github/workflows/main.yml | 123 +++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..f3a2bccfc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,123 @@ +# evaluating GitHub actions for CI, disconsider failures when evaluating PRs +# +# this is still missing: +# - deploy +# - coverage +# - upload github notes +# +name: main + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + name: [ + "windows-py35", + "windows-py36", + "windows-py37", + "windows-py37-pluggy", + "windows-py38", + + "ubuntu-py35", + "ubuntu-py36", + "ubuntu-py37", + "ubuntu-py37-pluggy", + "ubuntu-py37-freeze", + "ubuntu-py38", + "ubuntu-pypy3", + + "macos-py37", + "macos-py38", + + "linting", + ] + + include: + - name: "windows-py35" + python: "3.5" + os: windows-latest + tox_env: "py35-xdist" + - name: "windows-py36" + python: "3.6" + os: windows-latest + tox_env: "py36-xdist" + - name: "windows-py37" + python: "3.7" + os: windows-latest + tox_env: "py37-twisted-numpy" + - name: "windows-py37-pluggy" + python: "3.7" + os: windows-latest + tox_env: "py37-pluggymaster-xdist" + - name: "windows-py38" + python: "3.8" + os: windows-latest + tox_env: "py38" + + - name: "ubuntu-py35" + python: "3.5" + os: ubuntu-latest + tox_env: "py35-xdist" + - name: "ubuntu-py36" + python: "3.6" + os: ubuntu-latest + tox_env: "py36-xdist" + - name: "ubuntu-py37" + python: "3.7" + os: ubuntu-latest + tox_env: "py37-lsof-numpy-oldattrs-pexpect-twisted" + - name: "ubuntu-py37-pluggy" + python: "3.7" + os: ubuntu-latest + tox_env: "py37-pluggymaster-xdist" + - name: "ubuntu-py37-freeze" + python: "3.7" + os: ubuntu-latest + tox_env: "py37-freeze" + - name: "ubuntu-py38" + python: "3.8" + os: ubuntu-latest + tox_env: "py38-xdist" + - name: "ubuntu-pypy3" + python: "pypy3" + os: ubuntu-latest + tox_env: "pypy3-xdist" + + - name: "macos-py37" + python: "3.7" + os: macos-latest + tox_env: "py37-xdist" + - name: "macos-py38" + python: "3.8" + os: macos-latest + tox_env: "py38-xdist" + + - name: "linting" + python: "3.7" + os: ubuntu-latest + tox_env: "linting,docs,doctesting" + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + - name: Test + run: tox -e ${{ matrix.tox_env }} From ab44d3d7337b1e93846dafe47c7357d69371f99d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 19 Dec 2019 16:01:04 -0800 Subject: [PATCH 06/22] Merge pull request #6360 from asottile/release-4.6.8 Preparing release version 4.6.8 --- doc/en/announce/index.rst | 3 +++ doc/en/announce/release-4.6.6.rst | 20 ++++++++++++++++++++ doc/en/announce/release-4.6.7.rst | 19 +++++++++++++++++++ doc/en/announce/release-4.6.8.rst | 20 ++++++++++++++++++++ doc/en/changelog.rst | 23 +++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 doc/en/announce/release-4.6.6.rst create mode 100644 doc/en/announce/release-4.6.7.rst create mode 100644 doc/en/announce/release-4.6.8.rst diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index e44ab212e..22a702142 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -20,6 +20,9 @@ Release announcements release-5.1.0 release-5.0.1 release-5.0.0 + release-4.6.8 + release-4.6.7 + release-4.6.6 release-4.6.5 release-4.6.4 release-4.6.3 diff --git a/doc/en/announce/release-4.6.6.rst b/doc/en/announce/release-4.6.6.rst new file mode 100644 index 000000000..c47a31695 --- /dev/null +++ b/doc/en/announce/release-4.6.6.rst @@ -0,0 +1,20 @@ +pytest-4.6.6 +======================================= + +pytest 4.6.6 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/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* Bruno Oliveira +* Michael Goerz + + +Happy testing, +The pytest Development Team diff --git a/doc/en/announce/release-4.6.7.rst b/doc/en/announce/release-4.6.7.rst new file mode 100644 index 000000000..0e6cf6a95 --- /dev/null +++ b/doc/en/announce/release-4.6.7.rst @@ -0,0 +1,19 @@ +pytest-4.6.7 +======================================= + +pytest 4.6.7 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/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Bruno Oliveira +* Daniel Hahler + + +Happy testing, +The pytest Development Team diff --git a/doc/en/announce/release-4.6.8.rst b/doc/en/announce/release-4.6.8.rst new file mode 100644 index 000000000..3c04e5dbe --- /dev/null +++ b/doc/en/announce/release-4.6.8.rst @@ -0,0 +1,20 @@ +pytest-4.6.8 +======================================= + +pytest 4.6.8 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/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* Bruno Oliveira +* Ryan Mast + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 88f07ba69..be183d30a 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -815,6 +815,29 @@ Improved Documentation - `#5416 `_: Fix PytestUnknownMarkWarning in run/skip example. +pytest 4.6.8 (2019-12-19) +========================= + +Features +-------- + +- `#5471 `_: JUnit XML now includes a timestamp and hostname in the testsuite tag. + + + +Bug Fixes +--------- + +- `#5430 `_: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase. + + + +Trivial/Internal Changes +------------------------ + +- `#6345 `_: Pin ``colorama`` to ``0.4.1`` only for Python 3.4 so newer Python versions can still receive colorama updates. + + pytest 4.6.7 (2019-12-05) ========================= From 994909270f76a51841b3ad05677dfa42ea48f8b7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 20 Dec 2019 08:54:44 -0300 Subject: [PATCH 07/22] Update release notes script after CHANGELOG changed location --- .travis.yml | 4 ++-- ...gh_release_notes.py => publish-gh-release-notes.py} | 10 ++++++++-- tox.ini | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) rename scripts/{publish_gh_release_notes.py => publish-gh-release-notes.py} (94%) diff --git a/.travis.yml b/.travis.yml index e3edbfe9b..35ca8a69c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,9 +80,9 @@ jobs: addons: apt: packages: - # required by publish_gh_release_notes + # required by publish-gh-release-notes - pandoc - after_deploy: tox -e publish_gh_release_notes + after_deploy: tox -e publish-gh-release-notes deploy: provider: pypi user: nicoddemus diff --git a/scripts/publish_gh_release_notes.py b/scripts/publish-gh-release-notes.py similarity index 94% rename from scripts/publish_gh_release_notes.py rename to scripts/publish-gh-release-notes.py index 23f7b40ad..34ccaa63d 100644 --- a/scripts/publish_gh_release_notes.py +++ b/scripts/publish-gh-release-notes.py @@ -6,7 +6,13 @@ This script is meant to be executed after a successful deployment in Travis. Uses the following environment variables: * GIT_TAG: the name of the tag of the current commit. -* GH_RELEASE_NOTES_TOKEN: a personal access token with 'repo' permissions. It should be encrypted using: +* GH_RELEASE_NOTES_TOKEN: a personal access token with 'repo' permissions. + + Create one at: + + https://github.com/settings/tokens + + It should be encrypted using: $travis encrypt GH_RELEASE_NOTES_TOKEN= -r pytest-dev/pytest @@ -33,7 +39,7 @@ def publish_github_release(slug, token, tag_name, body): def parse_changelog(tag_name): - p = Path(__file__).parent.parent / "CHANGELOG.rst" + p = Path(__file__).parent.parent / "doc/en/changelog.rst" changelog_lines = p.read_text(encoding="UTF-8").splitlines() title_regex = re.compile(r"pytest (\d\.\d+\.\d+) \(\d{4}-\d{2}-\d{2}\)") diff --git a/tox.ini b/tox.ini index 71f795316..d33a62224 100644 --- a/tox.ini +++ b/tox.ini @@ -127,7 +127,7 @@ deps = towncrier commands = python scripts/release.py {posargs} -[testenv:publish_gh_release_notes] +[testenv:publish-gh-release-notes] description = create GitHub release after deployment basepython = python3 usedevelop = True @@ -135,7 +135,7 @@ passenv = GH_RELEASE_NOTES_TOKEN TRAVIS_TAG TRAVIS_REPO_SLUG deps = github3.py pypandoc -commands = python scripts/publish_gh_release_notes.py +commands = python scripts/publish-gh-release-notes.py {posargs} [pytest] From 6cd61390c260055c3637c7a0c08e74a75f31a3cd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 20 Dec 2019 13:18:49 -0800 Subject: [PATCH 08/22] Improve docs so regen doesn't leak temp directories --- doc/en/fixture.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 08305a5cc..db06a4015 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -1035,15 +1035,19 @@ file: # content of conftest.py - import pytest - import tempfile import os + import shutil + import tempfile + + import pytest @pytest.fixture() def cleandir(): newpath = tempfile.mkdtemp() os.chdir(newpath) + yield + shutil.rmtree(newpath) and declare its use in a test module via a ``usefixtures`` marker: From 73702ca88b28d8f83dc7487b87ef6633697cc7a6 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 23 Dec 2019 10:38:27 +0000 Subject: [PATCH 09/22] Improve warnings docs * Rearrange section about context manager to be in order * Link to `pytest.warns` and `recwarn` since a reader going top to bottom won't have seen about those yet. * Used only context manager form in the example; the call form is somewhat obsolete and is mentioned in the reference docs already. * Reuse the 'myfunction' from first example on the second one Co-Authored-By: Hugo van Kemenade Co-Authored-By: Hugo van Kemenade --- doc/en/warnings.rst | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 4b8be4469..013564c2d 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -198,7 +198,7 @@ the regular expression ``".*U.*mode is deprecated"``. Ensuring code triggers a deprecation warning -------------------------------------------- -You can also call a global helper for checking +You can also use :func:`pytest.deprecated_call` for checking that a certain function call triggers a ``DeprecationWarning`` or ``PendingDeprecationWarning``: @@ -207,13 +207,18 @@ that a certain function call triggers a ``DeprecationWarning`` or import pytest - def test_global(): - pytest.deprecated_call(myfunction, 17) + def test_myfunction_deprecated(): + with pytest.deprecated_call(): + myfunction(17) + +This test will fail if ``myfunction`` does not issue a deprecation warning +when called with a ``17`` argument. By default, ``DeprecationWarning`` and ``PendingDeprecationWarning`` will not be -caught when using ``pytest.warns`` or ``recwarn`` because default Python warnings filters hide -them. If you wish to record them in your own code, use the -command ``warnings.simplefilter('always')``: +caught when using :func:`pytest.warns` or :ref:`recwarn ` because +the default Python warnings filters hide +them. If you wish to record them in your own code, use +``warnings.simplefilter('always')``: .. code-block:: python @@ -223,19 +228,13 @@ command ``warnings.simplefilter('always')``: def test_deprecation(recwarn): warnings.simplefilter("always") - warnings.warn("deprecated", DeprecationWarning) + myfunction(17) assert len(recwarn) == 1 assert recwarn.pop(DeprecationWarning) -You can also use it as a contextmanager: - -.. code-block:: python - - def test_global(): - with pytest.deprecated_call(): - myobject.deprecated_method() - +The :ref:`recwarn ` fixture automatically ensures to reset the warnings +filter at the end of the test, so no global state is leaked. .. _`asserting warnings`: From 8de9b1be5629d70a9ce777bb350db229724382d8 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sat, 9 Nov 2019 16:00:35 +0200 Subject: [PATCH 10/22] Test on Python 3.8 --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f18ce0887..a6d856d91 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,6 +39,9 @@ jobs: py37-pluggymaster-xdist: python.version: '3.7' tox.env: 'py37-pluggymaster-xdist' + py38-xdist: + python.version: '3.8' + tox.env: 'py38-xdist' maxParallel: 10 steps: From a5863ca7608da8ce609711ac57cebf647700bf24 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 30 Dec 2019 09:41:21 +0100 Subject: [PATCH 11/22] minor: split doc with _early_rewrite_bailout --- src/_pytest/assertion/rewrite.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 25e726f2c..77ae70411 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -143,10 +143,12 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder): exec(co, module.__dict__) def _early_rewrite_bailout(self, name, state): - """This is a fast way to get out of rewriting modules. Profiling has - shown that the call to PathFinder.find_spec (inside of the find_spec - from this class) is a major slowdown, so, this method tries to - filter what we're sure won't be rewritten before getting to it. + """This is a fast way to get out of rewriting modules. + + Profiling has shown that the call to PathFinder.find_spec (inside of + the find_spec from this class) is a major slowdown, so, this method + tries to filter what we're sure won't be rewritten before getting to + it. """ if self.session is not None and not self._session_paths_checked: self._session_paths_checked = True From 1c0242dec122cf6fadcb5097cb655d05ce9545ce Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 30 Dec 2019 17:08:52 +0100 Subject: [PATCH 12/22] Fix `RunResult.parseoutcomes` (follow-up to #6353) --- changelog/6532.bugfix.rst | 2 +- src/_pytest/pytester.py | 13 +++++++++---- testing/test_pytester.py | 12 +++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/changelog/6532.bugfix.rst b/changelog/6532.bugfix.rst index dbfa0534d..b5c7cf771 100644 --- a/changelog/6532.bugfix.rst +++ b/changelog/6532.bugfix.rst @@ -1 +1 @@ -Fix problem with ``testdir`` not recognizing errors correctly in runs with a single test. +Fix parsing of outcomes containing multiple errors with ``testdir`` results (regression in 5.3.0). diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 490649ad7..c279fca88 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -433,9 +433,14 @@ class RunResult: for line in reversed(self.outlines): if rex_session_duration.search(line): outcomes = rex_outcome.findall(line) - return {noun: int(count) for (count, noun) in outcomes} - - raise ValueError("Pytest terminal summary report not found") + ret = {noun: int(count) for (count, noun) in outcomes} + break + else: + raise ValueError("Pytest terminal summary report not found") + if "errors" in ret: + assert "error" not in ret + ret["error"] = ret.pop("errors") + return ret def assert_outcomes( self, @@ -456,7 +461,7 @@ class RunResult: "passed": d.get("passed", 0), "skipped": d.get("skipped", 0), "failed": d.get("failed", 0), - "error": d.get("error", 0) + d.get("errors", 0), + "error": d.get("error", 0), "xpassed": d.get("xpassed", 0), "xfailed": d.get("xfailed", 0), } diff --git a/testing/test_pytester.py b/testing/test_pytester.py index fe0002b64..0015e489a 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -684,8 +684,9 @@ def test_run_result_repr(): ) -def test_run_pytester_with_single_test(testdir): - testcode = """ +def test_testdir_outcomes_with_multiple_errors(testdir): + p1 = testdir.makepyfile( + """ import pytest @pytest.fixture @@ -698,7 +699,8 @@ def test_run_pytester_with_single_test(testdir): def test_error2(bad_fixture): pass """ - - testdir.makepyfile(testcode) - result = testdir.runpytest() + ) + result = testdir.runpytest(str(p1)) result.assert_outcomes(error=2) + + assert result.parseoutcomes() == {"error": 2} From 9811ebdc5777aac1d9a17eba320528a050256324 Mon Sep 17 00:00:00 2001 From: PaulC Date: Tue, 31 Dec 2019 10:32:31 +1100 Subject: [PATCH 13/22] Added how to reserve an issue to yourself when contributing --- CONTRIBUTING.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a3ae731e4..bebd23ed2 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -51,7 +51,8 @@ Fix bugs Look through the `GitHub issues for bugs `_. -:ref:`Talk ` to developers to find out how you can fix specific bugs. +:ref:`Talk ` to developers to find out how you can fix specific bugs. To indicate that you are going +to work on a particular issue, add a comment to that effect on the specific issue. Don't forget to check the issue trackers of your favourite plugins, too! From d884164160300fff3d04a5f741d99cf4d9a45283 Mon Sep 17 00:00:00 2001 From: PaulC Date: Tue, 31 Dec 2019 12:49:37 +1100 Subject: [PATCH 14/22] removed trailing whitespace to fix linting issue --- CONTRIBUTING.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index bebd23ed2..455998b78 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -51,7 +51,7 @@ Fix bugs Look through the `GitHub issues for bugs `_. -:ref:`Talk ` to developers to find out how you can fix specific bugs. To indicate that you are going +:ref:`Talk ` to developers to find out how you can fix specific bugs. To indicate that you are going to work on a particular issue, add a comment to that effect on the specific issue. Don't forget to check the issue trackers of your favourite plugins, too! From deb4287d1c3c7980a065e975dbfdeeb7b5fcb7b6 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 4 Jan 2020 07:21:11 -0300 Subject: [PATCH 15/22] Update copyright year to 2020 Merge pull request #6392 from hugovk/4.6-maintenance-2020 --- LICENSE | 2 +- README.rst | 2 +- doc/en/conf.py | 4 ++-- doc/en/index.rst | 2 +- doc/en/license.rst | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index 477af2d2e..d14fb7ff4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2004-2019 Holger Krekel and others +Copyright (c) 2004-2020 Holger Krekel and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.rst b/README.rst index 15ab4f0bc..36f26d14e 100644 --- a/README.rst +++ b/README.rst @@ -145,7 +145,7 @@ Tidelift will coordinate the fix and disclosure. License ------- -Copyright Holger Krekel and others, 2004-2019. +Copyright Holger Krekel and others, 2004-2020. Distributed under the terms of the `MIT`_ license, pytest is free and open source software. diff --git a/doc/en/conf.py b/doc/en/conf.py index 7e8a2f209..3fb6002bc 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -66,7 +66,7 @@ master_doc = "contents" # General information about the project. project = "pytest" -copyright = "2015–2019, holger krekel and pytest-dev team" +copyright = "2015–2020, holger krekel and pytest-dev team" # The language for content autogenerated by Sphinx. Refer to documentation @@ -289,7 +289,7 @@ man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu" epub_title = "pytest" epub_author = "holger krekel at merlinux eu" epub_publisher = "holger krekel at merlinux eu" -epub_copyright = "2013, holger krekel et alii" +epub_copyright = "2013-2020, holger krekel et alii" # The language of the text. It defaults to the language option # or en if the language is not set. diff --git a/doc/en/index.rst b/doc/en/index.rst index d84bcd06d..806c498c7 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -120,7 +120,7 @@ Tidelift will coordinate the fix and disclosure. License ------- -Copyright Holger Krekel and others, 2004-2017. +Copyright Holger Krekel and others, 2004-2020. Distributed under the terms of the `MIT`_ license, pytest is free and open source software. diff --git a/doc/en/license.rst b/doc/en/license.rst index d94b34a99..c6c10bbf3 100644 --- a/doc/en/license.rst +++ b/doc/en/license.rst @@ -9,7 +9,7 @@ Distributed under the terms of the `MIT`_ license, pytest is free and open sourc The MIT License (MIT) - Copyright (c) 2004-2019 Holger Krekel and others + Copyright (c) 2004-2020 Holger Krekel and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 4fa819e5352e3b4ba21b547eee5bd0f8cdcd6f98 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 4 Jan 2020 09:39:49 -0300 Subject: [PATCH 16/22] Update py27/py34 deprecation docs I've updated the text and incorporated the topics from #5275, so this can now be part of the official docs, and #5275 can be closed/unpinned. Closes #5275 --- doc/en/py27-py34-deprecation.rst | 108 +++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 21 deletions(-) diff --git a/doc/en/py27-py34-deprecation.rst b/doc/en/py27-py34-deprecation.rst index a8258145f..f09ee3aa4 100644 --- a/doc/en/py27-py34-deprecation.rst +++ b/doc/en/py27-py34-deprecation.rst @@ -1,31 +1,97 @@ -Python 2.7 and 3.4 support plan -=============================== +Python 2.7 and 3.4 support +========================== -Python 2.7 EOL is fast approaching, with -upstream support `ending in 2020 `__. -Python 3.4's last release is scheduled for -`March 2019 `__. pytest is one of -the participating projects of the https://python3statement.org. +It is demanding on the maintainers of an open source project to support many Python versions, as +there's extra cost of keeping code compatible between all versions, while holding back on +features only made possible on newer Python versions. -The **pytest 4.6** series is the last to support Python 2.7 and 3.4, and was released in -**June 2019**. **pytest 5.0** and onwards will support only Python 3.5+. +In case of Python 2 and 3, the difference between the languages makes it even more prominent, +because many new Python 3 features cannot be used in a Python 2/3 compatible code base. -Thanks to the `python_requires`_ ``setuptools`` option, -Python 2.7 and Python 3.4 users using a modern ``pip`` version -will install the last pytest ``4.6`` version automatically even if ``5.0`` or later +Python 2.7 EOL has been reached `in 2020 `__, with +the last release planned for mid-April, 2020. + +Python 3.4 EOL has been reached `in 2019 `__, with the last release made in March, 2019. + +For those reasons, in Jun 2019 it was decided that **pytest 4.6** series will be the last to support Python 2.7 and 3.4. + +What this means for general users +--------------------------------- + +Thanks to the `python_requires`_ setuptools option, +Python 2.7 and Python 3.4 users using a modern pip version +will install the last pytest 4.6.X version automatically even if 5.0 or later versions are available on PyPI. -While pytest ``5.0`` will be the new mainstream and development version, until **January 2020** -the pytest core team plans to make bug-fix releases of the pytest ``4.6`` series by -back-porting patches to the ``4.6-maintenance`` branch that affect Python 2 users. +Users should ensure they are using the latest pip and setuptools versions for this to work. -**After 2020**, the core team will no longer actively backport patches, but the ``4.6-maintenance`` -branch will continue to exist so the community itself can contribute patches. The core team will -be happy to accept those patches and make new ``4.6`` releases **until mid-2020**. +Maintenance of 4.6.X versions +----------------------------- + +Until January 2020, the pytest core team ported many bug-fixes from the main release into the +``4.6-maintenance`` branch, with several 4.6.X releases being made along the year. + +From now on, the core team will **no longer actively backport patches**, but the ``4.6-maintenance`` +branch will continue to exist so the community itself can contribute patches. + +The core team will be happy to accept those patches, and make new 4.6.X releases **until mid-2020** +(but consider that date as a ballpark, after that date the team might still decide to make new releases +for critical bugs). .. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires -Technical Aspects ------------------ +Technical aspects +~~~~~~~~~~~~~~~~~ -The technical aspects of the Python 2.7 and 3.4 support plan (such as when releases will occur, how to backport fixes, etc) is described in issue `#5275 `__. +(This section is a transcript from `#5275 `__). + +In this section we describe the technical aspects of the Python 2.7 and 3.4 support plan. + +What goes into 4.6.X releases ++++++++++++++++++++++++++++++ + +New 4.6.X releases will contain bug fixes only. + +When will 4.6.X releases happen ++++++++++++++++++++++++++++++++ + +New 4.6.X releases will happen after we have a few bugs in place to release, or if a few weeks have +passed (say a single bug has been fixed a month after the latest 4.6.X release). + +No hard rules here, just ballpark. + +Who will handle applying bug fixes +++++++++++++++++++++++++++++++++++ + +We core maintainers expect that people still using Python 2.7/3.4 and being affected by +bugs to step up and provide patches and/or port bug fixes from the active branches. + +We will be happy to guide users interested in doing so, so please don't hesitate to ask. + +**Backporting changes into 4.6** + +Please follow these instructions: + +#. ``git fetch --all --prune`` + +#. ``git checkout origin/4.6-maintenance -b backport-XXXX`` # use the PR number here + +#. Locate the merge commit on the PR, in the *merged* message, for example: + + nicoddemus merged commit 0f8b462 into pytest-dev:features + +#. ``git cherry-pick -m1 REVISION`` # use the revision you found above (``0f8b462``). + +#. Open a PR targeting ``4.6-maintenance``: + + * Prefix the message with ``[4.6]`` so it is an obvious backport + * Delete the PR body, it usually contains a duplicate commit message. + +**Providing new PRs to 4.6** + +Fresh pull requests to ``4.6-maintenance`` will be accepted provided that +the equivalent code in the active branches does not contain that bug (for example, a bug is specific +to Python 2 only). + +Bug fixes that also happen in the mainstream version should be first fixed +there, and then backported as per instructions above. From 75f964c08d72bbca7b7342cf82986aa0b71c2633 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 4 Jan 2020 13:01:46 -0800 Subject: [PATCH 17/22] Merge pull request #6391 from asottile/release-4.6.9 Preparing release version 4.6.9 --- doc/en/announce/index.rst | 1 + doc/en/announce/release-4.6.9.rst | 21 +++++++++++++++++++++ doc/en/changelog.rst | 9 +++++++++ 3 files changed, 31 insertions(+) create mode 100644 doc/en/announce/release-4.6.9.rst diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 22a702142..7bcf899d9 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -20,6 +20,7 @@ Release announcements release-5.1.0 release-5.0.1 release-5.0.0 + release-4.6.9 release-4.6.8 release-4.6.7 release-4.6.6 diff --git a/doc/en/announce/release-4.6.9.rst b/doc/en/announce/release-4.6.9.rst new file mode 100644 index 000000000..ae0478c52 --- /dev/null +++ b/doc/en/announce/release-4.6.9.rst @@ -0,0 +1,21 @@ +pytest-4.6.9 +======================================= + +pytest 4.6.9 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/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* Bruno Oliveira +* Felix Yan +* Hugo + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index be183d30a..cb41e05e2 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -815,6 +815,15 @@ Improved Documentation - `#5416 `_: Fix PytestUnknownMarkWarning in run/skip example. +pytest 4.6.9 (2020-01-04) +========================= + +Bug Fixes +--------- + +- `#6301 `_: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``). + + pytest 4.6.8 (2019-12-19) ========================= From 0e0006934019aba7a3bbec95e2fac7c1b82d1063 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 6 Jan 2020 21:16:23 -0300 Subject: [PATCH 18/22] Fix serialization of 'None' reprcrashes Tracebacks coming from remote processes crated by the multiprocess module will contain "RemoteTracebacks" which don't have a 'reprcrash' attribute Fix #5971 --- changelog/5971.bugfix.rst | 2 ++ src/_pytest/reports.py | 14 ++++++--- testing/test_reports.py | 62 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 changelog/5971.bugfix.rst diff --git a/changelog/5971.bugfix.rst b/changelog/5971.bugfix.rst new file mode 100644 index 000000000..dbc79dd96 --- /dev/null +++ b/changelog/5971.bugfix.rst @@ -0,0 +1,2 @@ +Fix a ``pytest-xdist`` crash when dealing with exceptions raised in subprocesses created by the +``multiprocessing`` module. diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 5d445c2f8..4c93013d6 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -374,8 +374,11 @@ def _report_to_json(report): ] return result - def serialize_repr_crash(reprcrash): - return reprcrash.__dict__.copy() + def serialize_repr_crash(reprcrash: Optional[ReprFileLocation]): + if reprcrash is not None: + return reprcrash.__dict__.copy() + else: + return None def serialize_longrepr(rep): result = { @@ -455,8 +458,11 @@ def _report_kwargs_from_json(reportdict): ] return ReprTraceback(**repr_traceback_dict) - def deserialize_repr_crash(repr_crash_dict): - return ReprFileLocation(**repr_crash_dict) + def deserialize_repr_crash(repr_crash_dict: Optional[dict]): + if repr_crash_dict is not None: + return ReprFileLocation(**repr_crash_dict) + else: + return None if ( reportdict["longrepr"] diff --git a/testing/test_reports.py b/testing/test_reports.py index ff813543c..f695965e9 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -305,6 +305,8 @@ class TestReportSerialization: data = report._to_json() loaded_report = report_class._from_json(data) + + assert loaded_report.failed check_longrepr(loaded_report.longrepr) # make sure we don't blow up on ``toterminal`` call; we don't test the actual output because it is very @@ -312,6 +314,66 @@ class TestReportSerialization: # elsewhere and we do check the contents of the longrepr object after loading it. loaded_report.longrepr.toterminal(tw_mock) + def test_chained_exceptions_no_reprcrash( + self, testdir, tw_mock, + ): + """Regression test for tracebacks without a reprcrash (#5971) + + This happens notably on exceptions raised by multiprocess.pool: the exception transfer + from subprocess to main process creates an artificial exception which, ExceptionInfo + can't obtain the ReprFileLocation from. + """ + testdir.makepyfile( + """ + # equivalent of multiprocessing.pool.RemoteTraceback + class RemoteTraceback(Exception): + def __init__(self, tb): + self.tb = tb + def __str__(self): + return self.tb + + def test_a(): + try: + raise ValueError('value error') + except ValueError as e: + # equivalent to how multiprocessing.pool.rebuild_exc does it + e.__cause__ = RemoteTraceback('runtime error') + raise e + """ + ) + reprec = testdir.inline_run() + + reports = reprec.getreports("pytest_runtest_logreport") + + def check_longrepr(longrepr): + assert isinstance(longrepr, ExceptionChainRepr) + assert len(longrepr.chain) == 2 + entry1, entry2 = longrepr.chain + tb1, fileloc1, desc1 = entry1 + tb2, fileloc2, desc2 = entry2 + + assert "RemoteTraceback: runtime error" in str(tb1) + assert "ValueError('value error')" in str(tb2) + + assert fileloc1 is None + assert fileloc2.message == "ValueError: value error" + + # 3 reports: setup/call/teardown: get the call report + assert len(reports) == 3 + report = reports[1] + + assert report.failed + check_longrepr(report.longrepr) + + data = report._to_json() + loaded_report = TestReport._from_json(data) + + assert loaded_report.failed + check_longrepr(loaded_report.longrepr) + + # for same reasons as previous test, ensure we don't blow up here + loaded_report.longrepr.toterminal(tw_mock) + class TestHooks: """Test that the hooks are working correctly for plugins""" From 8dbf6a4b2d89b8cbffe53ee39aa98c27fe4714d8 Mon Sep 17 00:00:00 2001 From: Marcelo Duarte Trevisani Date: Tue, 7 Jan 2020 11:07:05 +0000 Subject: [PATCH 19/22] Unifying black version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcab794c6..4ebbd6d18 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: rev: v1.0.0 hooks: - id: blacken-docs - additional_dependencies: [black==19.3b0] + additional_dependencies: [black==19.10b0] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.2.3 hooks: From 356d865ad71be56b083c8f1ac8065f6cbec056b8 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 7 Jan 2020 12:45:18 -0300 Subject: [PATCH 20/22] Use concurrent.futures for fidelity to the original report As requested in review --- testing/test_reports.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/testing/test_reports.py b/testing/test_reports.py index f695965e9..d0bafec23 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -320,25 +320,19 @@ class TestReportSerialization: """Regression test for tracebacks without a reprcrash (#5971) This happens notably on exceptions raised by multiprocess.pool: the exception transfer - from subprocess to main process creates an artificial exception which, ExceptionInfo + from subprocess to main process creates an artificial exception, which ExceptionInfo can't obtain the ReprFileLocation from. """ testdir.makepyfile( """ - # equivalent of multiprocessing.pool.RemoteTraceback - class RemoteTraceback(Exception): - def __init__(self, tb): - self.tb = tb - def __str__(self): - return self.tb + from concurrent.futures import ProcessPoolExecutor + + def func(): + raise ValueError('value error') def test_a(): - try: - raise ValueError('value error') - except ValueError as e: - # equivalent to how multiprocessing.pool.rebuild_exc does it - e.__cause__ = RemoteTraceback('runtime error') - raise e + with ProcessPoolExecutor() as p: + p.submit(func).result() """ ) reprec = testdir.inline_run() @@ -352,8 +346,8 @@ class TestReportSerialization: tb1, fileloc1, desc1 = entry1 tb2, fileloc2, desc2 = entry2 - assert "RemoteTraceback: runtime error" in str(tb1) - assert "ValueError('value error')" in str(tb2) + assert "RemoteTraceback" in str(tb1) + assert "ValueError: value error" in str(tb2) assert fileloc1 is None assert fileloc2.message == "ValueError: value error" From 23475b6ab95a40ad35b676637aea885fa777a3fd Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 9 Jan 2020 18:06:15 -0300 Subject: [PATCH 21/22] Fix wrong 'changelog' and 'reference' links in docs Both references were referencing links from Python because of our intersphinx mapping in `conf.py`: intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} Because Python's docs explicitly define both references, Sphinx fallbacks to them instead of generating implicit references as was expected. Fix #6397 --- doc/en/changelog.rst | 2 ++ doc/en/reference.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index cb41e05e2..4703c7e67 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -1,3 +1,5 @@ +.. _`changelog`: + ========= Changelog ========= diff --git a/doc/en/reference.rst b/doc/en/reference.rst index a056fdf28..50e32d660 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -1,3 +1,5 @@ +.. _`reference`: + API Reference ============= From 36531599a4192c9c4f4f39ecdf2cdb32cde91628 Mon Sep 17 00:00:00 2001 From: Ryan Barner Date: Thu, 9 Jan 2020 14:12:57 -0800 Subject: [PATCH 22/22] Fix grammar in README Corrects grammar error in "Support pytest" section. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 36f26d14e..3235dd4c2 100644 --- a/README.rst +++ b/README.rst @@ -112,7 +112,7 @@ Support pytest -------------- `Open Collective`_ is an online funding platform for open and transparent communities. -It provide tools to raise money and share your finances in full transparency. +It provides tools to raise money and share your finances in full transparency. It is the platform of choice for individuals and companies that want to make one-time or monthly donations directly to the project.