Update to 7.0.0rc1

This commit is contained in:
Miro Hrončok 2021-12-15 18:57:11 +01:00
parent d5e92167f0
commit 7faf670b11
4 changed files with 16 additions and 122 deletions

View File

@ -1,76 +0,0 @@
From 78fb97105f38dc286353bbc331a243b6e753fe3c Mon Sep 17 00:00:00 2001
From: Petr Viktorin <encukou@gmail.com>
Date: Wed, 6 Jan 2021 13:33:33 +0100
Subject: [PATCH 1/2] Make code.FormattedExcinfo.get_source more defensive
When line_index was a large negative number, get_source failed
on `source.lines[line_index]`.
Use the same dummy Source as with a large positive line_index.
---
src/_pytest/_code/code.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py
index b852175606..af3bdf0561 100644
--- a/src/_pytest/_code/code.py
+++ b/src/_pytest/_code/code.py
@@ -721,11 +721,11 @@ def get_source(
) -> List[str]:
"""Return formatted and marked up source lines."""
lines = []
- if source is None or line_index >= len(source.lines):
+ if source is not None and line_index < 0:
+ line_index += len(source.lines)
+ if source is None or line_index >= len(source.lines) or line_index < 0:
source = Source("???")
line_index = 0
- if line_index < 0:
- line_index += len(source)
space_prefix = " "
if short:
lines.append(space_prefix + source.lines[line_index].strip())
From 0a75c8e57b4b87ee533f3b08612590704b6743bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 22 Apr 2021 19:13:44 +0200
Subject: [PATCH 2/2] Add a regression test for a more defensive
code.FormattedExcinfo.get_source
---
testing/code/test_excinfo.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py
index e6a9cbaf73..287733dac7 100644
--- a/testing/code/test_excinfo.py
+++ b/testing/code/test_excinfo.py
@@ -1397,6 +1397,29 @@ def test(tmp_path):
result.stderr.no_fnmatch_line("*INTERNALERROR*")
+def test_regression_nagative_line_index(pytester):
+ """
+ With Python 3.10 alphas, there was an INTERNALERROR reported in
+ https://github.com/pytest-dev/pytest/pull/8227
+ This test ensures it does not regress.
+ """
+ pytester.makepyfile(
+ """
+ import ast
+ import pytest
+
+
+ def test_literal_eval():
+ with pytest.raises(ValueError, match="^$"):
+ ast.literal_eval("pytest")
+ """
+ )
+ result = pytester.runpytest()
+ result.stdout.fnmatch_lines(["* 1 failed in *"])
+ result.stdout.no_fnmatch_line("*INTERNALERROR*")
+ result.stderr.no_fnmatch_line("*INTERNALERROR*")
+
+
@pytest.mark.usefixtures("limited_recursion_depth")
def test_exception_repr_extraction_error_on_recursion():
"""

View File

@ -1,27 +0,0 @@
From d9635d560d30fd732c878a9f5fbddd85d4345a48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Wed, 12 May 2021 13:30:46 +0200
Subject: [PATCH] Ignore DeprecationWarnings in test_trial_error
Fixes https://github.com/pytest-dev/pytest/issues/8663
---
testing/test_unittest.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testing/test_unittest.py b/testing/test_unittest.py
index 8b00cb8..de8fc5c 100644
--- a/testing/test_unittest.py
+++ b/testing/test_unittest.py
@@ -533,7 +533,9 @@ class TestTrialUnittest:
# will crash both at test time and at teardown
"""
)
- result = testdir.runpytest("-vv", "-oconsole_output_style=classic")
+ result = testdir.runpytest(
+ "-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
+ )
result.stdout.fnmatch_lines(
[
"test_trial_error.py::TC::test_four FAILED",

View File

@ -1,20 +1,12 @@
Name: pytest Name: pytest
Version: 6.2.5 %global base_version 7.0.0
Release: 2%{?dist} %global prerelease rc1
Version: %{base_version}%{?prerelease:~%{prerelease}}
Release: 1%{?dist}
Summary: Simple powerful testing with Python Summary: Simple powerful testing with Python
License: MIT License: MIT
URL: https://pytest.org URL: https://pytest.org
Source0: %{pypi_source} Source0: %{pypi_source pytest %{base_version}%{?prerelease}}
# Make code.FormattedExcinfo.get_source more defensive
# Merged upstream, https://github.com/pytest-dev/pytest/pull/8227
# Rebased slightly
Patch1: 8227.patch
# Ignore DeprecationWarnings in test_trial_error
# Merged upstream, https://github.com/pytest-dev/pytest/pull/8664
# Rebased slightly
Patch3: 8664.patch
# When building pytest for the first time with new Python version # When building pytest for the first time with new Python version
# we might not yet have all the BRs, those conditionals allow us to do that. # we might not yet have all the BRs, those conditionals allow us to do that.
@ -44,15 +36,16 @@ BuildRequires: python3-setuptools_scm
# Those are also runtime deps, needed for tests and docs # Those are also runtime deps, needed for tests and docs
# We keep them unconditionality, so we don't accidentally build pytest # We keep them unconditionality, so we don't accidentally build pytest
# before them and get broken dependencies # before them and get broken dependencies
BuildRequires: python3-attrs BuildRequires: python3-attrs >= 19.2
BuildRequires: python3-iniconfig BuildRequires: python3-iniconfig
BuildRequires: python3-packaging BuildRequires: python3-packaging
BuildRequires: python3-pluggy >= 0.12 BuildRequires: python3-pluggy >= 0.12
BuildRequires: python3-py >= 1.5.0 BuildRequires: python3-py >= 1.8.2
BuildRequires: python3-toml BuildRequires: python3-tomli >= 1
%if %{with tests} %if %{with tests}
BuildRequires: python3-hypothesis BuildRequires: python3-hypothesis >= 3.56
BuildRequires: python3-pygments >= 2.7.2
BuildRequires: python3-xmlschema BuildRequires: python3-xmlschema
%if %{with optional_tests} %if %{with optional_tests}
BuildRequires: python3-argcomplete BuildRequires: python3-argcomplete
@ -100,7 +93,7 @@ The pytest framework makes it easy to write small tests, yet scales to support
complex functional testing for applications and libraries. complex functional testing for applications and libraries.
%prep %prep
%autosetup -p1 -n %{name}-%{version} %autosetup -p1 -n %{name}-%{base_version}%{?prerelease}
%build %build
%py3_build %py3_build
@ -165,6 +158,10 @@ find %{buildroot}%{python3_sitelib} \
%{python3_sitelib}/pytest/ %{python3_sitelib}/pytest/
%changelog %changelog
* Fri Jan 21 2022 Miro Hrončok <mhroncok@redhat.com> - 7.0.0~rc1-1
- Update to 7.0.0rc1
- Fixes: rhbz#2029764
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 6.2.5-2 * Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 6.2.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (pytest-6.2.5.tar.gz) = 7624563a9d967da4cbf82cfff90bae8c0cca07b32e291dc7c5efa787725ed1a255edd066bf0d5fbd89b8cbed8cf5b619fe7c7017f44a7f8a014e3310c06bdbf9 SHA512 (pytest-7.0.0rc1.tar.gz) = 0e4643cea377f1e832850d382ee78689674df58f190171af037a3a5b1da7a3c0ca121353255d1a34156a6c581da281c1014356a24a44f101916fbc17b0eeef7b