From 40cb2f5b540ff0dae19bcf34f7ec81460f1d17c2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 15 Apr 2021 20:02:50 +0200 Subject: [PATCH 1/4] Backport training update (#8557) --- doc/en/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/index.rst b/doc/en/index.rst index 7c4d9394de9..b29c3a55c5c 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -2,7 +2,7 @@ .. sidebar:: Next Open Trainings - - `Professional testing with Python `_, via Python Academy, February 1-3 2021, remote and Leipzig (Germany). **Early-bird discount available until January 15th**. + - `Professionelles Testen für Python mit pytest `_ (German), part of the enterPy conference, April 22nd (sold out) and May 20th, remote. Also see `previous talks and blogposts `_. From 69ea076d55b2e17bb323aa67deedec7e9a43a036 Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Wed, 28 Apr 2021 07:01:45 -0500 Subject: [PATCH 2/4] Update fixture.rst Availability was misspelled. It was `availabiility` --- doc/en/fixture.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index c74984563ab..a3a1e9eb415 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -1124,7 +1124,7 @@ never have been made. .. _`conftest.py`: .. _`conftest`: -Fixture availabiility +Fixture availability --------------------- Fixture availability is determined from the perspective of the test. A fixture From d8d6812bdf2e5d12e3d57baab648df3e869950f0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 15 Apr 2021 08:55:42 -0300 Subject: [PATCH 3/4] Merge pull request #8540 from hauntsaninja/assert310 (cherry picked from commit af31c60db1dc4e513f47aabf8f6e844b23afd35f) --- AUTHORS | 1 + changelog/8539.bugfix.rst | 1 + src/_pytest/assertion/rewrite.py | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 changelog/8539.bugfix.rst diff --git a/AUTHORS b/AUTHORS index b35bebf7af3..2c690c5d28f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -273,6 +273,7 @@ Sankt Petersbug Segev Finer Serhii Mozghovyi Seth Junot +Shantanu Jain Shubham Adep Simon Gomizelj Simon Kerr diff --git a/changelog/8539.bugfix.rst b/changelog/8539.bugfix.rst new file mode 100644 index 00000000000..a2098610e29 --- /dev/null +++ b/changelog/8539.bugfix.rst @@ -0,0 +1 @@ +Fixed assertion rewriting on Python 3.10. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 805d4c8b35b..37ff076aab5 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -673,12 +673,9 @@ def run(self, mod: ast.Module) -> None: if not mod.body: # Nothing to do. return - # Insert some special imports at the top of the module but after any - # docstrings and __future__ imports. - aliases = [ - ast.alias("builtins", "@py_builtins"), - ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), - ] + + # We'll insert some special imports at the top of the module, but after any + # docstrings and __future__ imports, so first figure out where that is. doc = getattr(mod, "docstring", None) expect_docstring = doc is None if doc is not None and self.is_rewrite_disabled(doc): @@ -710,10 +707,27 @@ def run(self, mod: ast.Module) -> None: lineno = item.decorator_list[0].lineno else: lineno = item.lineno + # Now actually insert the special imports. + if sys.version_info >= (3, 10): + aliases = [ + ast.alias("builtins", "@py_builtins", lineno=lineno, col_offset=0), + ast.alias( + "_pytest.assertion.rewrite", + "@pytest_ar", + lineno=lineno, + col_offset=0, + ), + ] + else: + aliases = [ + ast.alias("builtins", "@py_builtins"), + ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), + ] imports = [ ast.Import([alias], lineno=lineno, col_offset=0) for alias in aliases ] mod.body[pos:pos] = imports + # Collect asserts. nodes: List[ast.AST] = [mod] while nodes: From 017dd1ccd60055bc6a7a41af11b74425da87a696 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Tue, 4 May 2021 15:19:09 +0000 Subject: [PATCH 4/4] Prepare release version 6.2.4 --- changelog/8539.bugfix.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-6.2.4.rst | 22 ++++++++++++++++++++++ doc/en/changelog.rst | 9 +++++++++ doc/en/getting-started.rst | 2 +- 5 files changed, 33 insertions(+), 2 deletions(-) delete mode 100644 changelog/8539.bugfix.rst create mode 100644 doc/en/announce/release-6.2.4.rst diff --git a/changelog/8539.bugfix.rst b/changelog/8539.bugfix.rst deleted file mode 100644 index a2098610e29..00000000000 --- a/changelog/8539.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed assertion rewriting on Python 3.10. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index f9720eab920..7751405a196 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-6.2.4 release-6.2.3 release-6.2.2 release-6.2.1 diff --git a/doc/en/announce/release-6.2.4.rst b/doc/en/announce/release-6.2.4.rst new file mode 100644 index 00000000000..fa2e3e78132 --- /dev/null +++ b/doc/en/announce/release-6.2.4.rst @@ -0,0 +1,22 @@ +pytest-6.2.4 +======================================= + +pytest 6.2.4 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: + +* Anthony Sottile +* Bruno Oliveira +* Christian Maurer +* Florian Bruhin +* Ran Benita + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index b4ffd08dac5..16b41bd78e5 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -28,6 +28,15 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 6.2.4 (2021-05-04) +========================= + +Bug Fixes +--------- + +- `#8539 `_: Fixed assertion rewriting on Python 3.10. + + pytest 6.2.3 (2021-04-03) ========================= diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index e1f7961e696..d876368d80a 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.2.3 + pytest 6.2.4 .. _`simpletest`: