Accepting request 965098 from home:bnavigator:branches:devel:languages:python:pytest

- Update to 7.1.1
  * #9767: Fixed a regression in pytest 7.1.0 where some
    conftest.py files outside of the source tree (e.g. in the
   [site-packages]{.title-ref} directory) were not picked up.
- python-pytest5 is gone. Remove the libalts stopgap
- Update to 7.1.0
  * Big changelog for 7.x series, see
    https://docs.pytest.org/en/7.1.x/changelog.html for details 
- Breaking changes:
  * #8838: As per our policy, the following features have been
    deprecated in the 6.X series and are now removed:
    + pytest._fillfuncargs function.
    + pytest_warning_captured hook - use pytest_warning_recorded
      instead.
    + -k -foobar syntax - use -k 'not foobar' instead.
    + -k foobar: syntax.
    * pytest.collect module - import from pytest directly.
  * #9437: Dropped support for Python 3.6, which reached
    end-of-life at 2021-12-23.
  * #7259: The Node.reportinfo() function first return value type
    has been expanded from py.path.local | str to os.PathLike[str]
    | str.
    Most plugins which refer to reportinfo() only define it as part
    of a custom pytest.Item implementation. Since py.path.local is
    a os.PathLike[str], these plugins are unaffacted.
    Plugins and users which call reportinfo(), use the first return
    value and interact with it as a py.path.local, would need to
    adjust by calling py.path.local(fspath). Although preferably,
    avoid the legacy py.path.local and use pathlib.Path, or use
    item.location or item.path, instead.
    Note: pytest was not able to provide a deprecation period for
    this change.
  * #8246: --version now writes version information to stdout
    rather than stderr.
  * #8733: Drop a workaround for pyreadline that made it work with
    --pdb. The workaround was introduced in #1281 in 2015, however
    since then pyreadline seems to have gone unmaintained, is
    generating warnings, and will stop working on Python 3.10.
  * #9061: Using pytest.approx() in a boolean context now raises an
    error hinting at the proper usage.
    It is apparently common for users to mistakenly use
    pytest.approx like this:
        assert pytest.approx(actual, expected)
    
    While the correct usage is:
        assert actual == pytest.approx(expected) 
        
    The new error message helps catch those mistakes.
  * #9277: The pytest.Instance collector type has been removed.
    Importing pytest.Instance or _pytest.python.Instance returns a
    dummy type and emits a deprecation warning. See The
    pytest.Instance collector for details.
  * If you have concerns about the removal of a specific feature,
    please add a comment to issue #9308.
- Drop patches
  * pytest-pr8664-py3.10-test_trial_error-fail.patch
  * pytest-pr9173-importlib-py310.patch
  * pytest-pr9417-py3.10.1-fail.patch

OBS-URL: https://build.opensuse.org/request/show/965098
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest?expand=0&rev=100
This commit is contained in:
Matej Cepl 2022-03-26 22:07:24 +00:00 committed by Git OBS Bridge
parent 4f25e945d5
commit 1f283a0f4d
7 changed files with 87 additions and 182 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89
size 1118720

3
pytest-7.1.1.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:841132caef6b1ad17a9afde46dc4f6cfa59a05f9555aae5151f73bdf2820ca63
size 1255528

View File

@ -1,25 +0,0 @@
From 51293de324fc04e778c753a0fd66cb10fe05bf14 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(-)
Index: pytest-6.2.5/testing/test_unittest.py
===================================================================
--- pytest-6.2.5.orig/testing/test_unittest.py
+++ pytest-6.2.5/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,83 +0,0 @@
Index: pytest-6.2.5/changelog/9169.bugfix.rst
===================================================================
--- /dev/null
+++ pytest-6.2.5/changelog/9169.bugfix.rst
@@ -0,0 +1 @@
+Support for the ``files`` API from ``importlib.resources`` within rewritten files.
Index: pytest-6.2.5/src/_pytest/assertion/rewrite.py
===================================================================
--- pytest-6.2.5.orig/src/_pytest/assertion/rewrite.py
+++ pytest-6.2.5/src/_pytest/assertion/rewrite.py
@@ -63,7 +63,7 @@ class AssertionRewritingHook(importlib.a
except ValueError:
self.fnpats = ["test_*.py", "*_test.py"]
self.session: Optional[Session] = None
- self._rewritten_names: Set[str] = set()
+ self._rewritten_names: Dict[str, Path] = {}
self._must_rewrite: Set[str] = set()
# flag to guard against trying to rewrite a pyc file while we are already writing another pyc file,
# which might result in infinite recursion (#3506)
@@ -133,7 +133,7 @@ class AssertionRewritingHook(importlib.a
fn = Path(module.__spec__.origin)
state = self.config._store[assertstate_key]
- self._rewritten_names.add(module.__name__)
+ self._rewritten_names[module.__name__] = fn
# The requested module looks like a test file, so rewrite it. This is
# the most magical part of the process: load the source, rewrite the
@@ -275,6 +275,14 @@ class AssertionRewritingHook(importlib.a
with open(pathname, "rb") as f:
return f.read()
+ if sys.version_info >= (3, 9):
+
+ def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore
+ from types import SimpleNamespace
+ from importlib.readers import FileReader
+
+ return FileReader(SimpleNamespace(path=self._rewritten_names[name]))
+
def _write_pyc_fp(
fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType
Index: pytest-6.2.5/testing/test_assertrewrite.py
===================================================================
--- pytest-6.2.5.orig/testing/test_assertrewrite.py
+++ pytest-6.2.5/testing/test_assertrewrite.py
@@ -771,6 +771,35 @@ class TestRewriteOnImport:
)
assert pytester.runpytest().ret == ExitCode.NO_TESTS_COLLECTED
+ @pytest.mark.skipif(
+ sys.version_info < (3, 9),
+ reason="importlib.resources.files was introduced in 3.9",
+ )
+ def test_load_resource_via_files_with_rewrite(self, pytester: Pytester) -> None:
+ example = pytester.path.joinpath("demo") / "example"
+ init = pytester.path.joinpath("demo") / "__init__.py"
+ pytester.makepyfile(
+ **{
+ "demo/__init__.py": """
+ from importlib.resources import files
+
+ def load():
+ return files(__name__)
+ """,
+ "test_load": f"""
+ pytest_plugins = ["demo"]
+
+ def test_load():
+ from demo import load
+ found = {{str(i) for i in load().iterdir() if i.name != "__pycache__"}}
+ assert found == {{{str(example)!r}, {str(init)!r}}}
+ """,
+ }
+ )
+ example.mkdir()
+
+ assert pytester.runpytest("-vv").ret == ExitCode.OK
+
def test_readonly(self, pytester: Pytester) -> None:
sub = pytester.mkdir("testing")
sub.joinpath("test_readonly.py").write_bytes(

View File

@ -1,49 +0,0 @@
From 913439f5e5691f391e2969b3c8f0a49e50dce43a Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <nicoddemus@gmail.com>
Date: Thu, 16 Dec 2021 09:07:14 -0300
Subject: [PATCH] Fix test_errors_in_xfail_skip_expressions for Python 3.10.1
Decided to remove the condition altogether as seems reasonable to state
that our own test suite requires Python 3.10.1.
Fix #9413
---
.github/workflows/main.yml | 4 ++--
testing/test_skipping.py | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
Index: pytest-6.2.5/.github/workflows/main.yml
===================================================================
--- pytest-6.2.5.orig/.github/workflows/main.yml
+++ pytest-6.2.5/.github/workflows/main.yml
@@ -75,7 +75,7 @@ jobs:
os: windows-latest
tox_env: "py39-xdist"
- name: "windows-py310"
- python: "3.10-dev"
+ python: "3.10.1"
os: windows-latest
tox_env: "py310-xdist"
@@ -105,7 +105,7 @@ jobs:
os: ubuntu-latest
tox_env: "py39-xdist"
- name: "ubuntu-py310"
- python: "3.10-dev"
+ python: "3.10.1"
os: ubuntu-latest
tox_env: "py310-xdist"
- name: "ubuntu-pypy3"
Index: pytest-6.2.5/testing/test_skipping.py
===================================================================
--- pytest-6.2.5.orig/testing/test_skipping.py
+++ pytest-6.2.5/testing/test_skipping.py
@@ -1126,8 +1126,6 @@ def test_errors_in_xfail_skip_expression
pypy_version_info = getattr(sys, "pypy_version_info", None)
if pypy_version_info is not None and pypy_version_info < (6,):
markline = markline[5:]
- elif sys.version_info[:2] >= (3, 10):
- markline = markline[11:]
elif sys.version_info >= (3, 8) or hasattr(sys, "pypy_version_info"):
markline = markline[4:]

View File

@ -1,3 +1,74 @@
-------------------------------------------------------------------
Fri Mar 25 23:39:31 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Update to 7.1.1
* #9767: Fixed a regression in pytest 7.1.0 where some
conftest.py files outside of the source tree (e.g. in the
[site-packages]{.title-ref} directory) were not picked up.
- python-pytest5 is gone. Remove the libalts stopgap
-------------------------------------------------------------------
Sun Mar 13 08:38:16 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Update to 7.1.0
* Big changelog for 7.x series, see
https://docs.pytest.org/en/7.1.x/changelog.html for details
- Breaking changes:
* #8838: As per our policy, the following features have been
deprecated in the 6.X series and are now removed:
+ pytest._fillfuncargs function.
+ pytest_warning_captured hook - use pytest_warning_recorded
instead.
+ -k -foobar syntax - use -k 'not foobar' instead.
+ -k foobar: syntax.
* pytest.collect module - import from pytest directly.
* #9437: Dropped support for Python 3.6, which reached
end-of-life at 2021-12-23.
* #7259: The Node.reportinfo() function first return value type
has been expanded from py.path.local | str to os.PathLike[str]
| str.
Most plugins which refer to reportinfo() only define it as part
of a custom pytest.Item implementation. Since py.path.local is
a os.PathLike[str], these plugins are unaffacted.
Plugins and users which call reportinfo(), use the first return
value and interact with it as a py.path.local, would need to
adjust by calling py.path.local(fspath). Although preferably,
avoid the legacy py.path.local and use pathlib.Path, or use
item.location or item.path, instead.
Note: pytest was not able to provide a deprecation period for
this change.
* #8246: --version now writes version information to stdout
rather than stderr.
* #8733: Drop a workaround for pyreadline that made it work with
--pdb. The workaround was introduced in #1281 in 2015, however
since then pyreadline seems to have gone unmaintained, is
generating warnings, and will stop working on Python 3.10.
* #9061: Using pytest.approx() in a boolean context now raises an
error hinting at the proper usage.
It is apparently common for users to mistakenly use
pytest.approx like this:
assert pytest.approx(actual, expected)
While the correct usage is:
assert actual == pytest.approx(expected)
The new error message helps catch those mistakes.
* #9277: The pytest.Instance collector type has been removed.
Importing pytest.Instance or _pytest.python.Instance returns a
dummy type and emits a deprecation warning. See The
pytest.Instance collector for details.
* If you have concerns about the removal of a specific feature,
please add a comment to issue #9308.
- Drop patches
* pytest-pr8664-py3.10-test_trial_error-fail.patch
* pytest-pr9173-importlib-py310.patch
* pytest-pr9417-py3.10.1-fail.patch
-------------------------------------------------------------------
Tue Dec 28 16:52:14 UTC 2021 - Ben Greiner <code@bnavigator.de>

View File

@ -1,7 +1,7 @@
#
# spec file
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,15 +16,12 @@
#
# https://build.opensuse.org/request/show/926611#comment-1560144
%bcond_with pytest_is_ready_for_alts
%if 0%{?suse_version} > 1500 && %{with pytest_is_ready_for_alts}
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -%{flavor}
@ -33,23 +30,20 @@
%define psuffix %{nil}
%bcond_with test
%endif
%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
Name: python-pytest%{psuffix}
Version: 6.2.5
Version: 7.1.1
Release: 0
Summary: Simple powerful testing with Python
License: MIT
URL: https://github.com/pytest-dev/pytest
Source: https://files.pythonhosted.org/packages/source/p/pytest/pytest-%{version}.tar.gz
# PATCH-FIX-UPSTREAM pytest-pr8664-py3.10-test_trial_error-fail.patch -- gh#pytest-dev/pytest#8664
Patch0: pytest-pr8664-py3.10-test_trial_error-fail.patch
# PATCH-FIX-UPSTREAM pytest-pr9173-importlib-py310.patch -- gh#pytest-dev/pytest#9173
Patch1: pytest-pr9173-importlib-py310.patch
# PATCH-FIX-UPSTREAM pytest-pr9417-py3.10.1-fail.patch -- gh#pytest-dev/pytest#9417
Patch2: pytest-pr9417-py3.10.1-fail.patch
BuildRequires: %{python_module setuptools >= 42.0}
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module toml}
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module setuptools_scm >= 6}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module tomli >= 1}
BuildRequires: fdupes
BuildRequires: python-rpm-macros >= 20210929
Requires: python-attrs >= 19.2.0
@ -59,8 +53,7 @@ Requires: python-packaging
Requires: python-pluggy >= 0.12
Requires: python-py >= 1.8.2
Requires: python-setuptools
Requires: python-toml
Requires: python-wcwidth
Requires: python-tomli >= 1
%if %{with libalternatives}
Requires: alts
BuildRequires: alts
@ -79,16 +72,13 @@ BuildRequires: %{python_module hypothesis >= 3.56}
# tests, when the package is not available.
# BuildRequires: %%{python_module nose}
BuildRequires: %{python_module pexpect}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module pygments-pytest}
BuildRequires: %{python_module pytest >= %{version}}
BuildRequires: %{python_module pytest-xdist}
BuildRequires: %{python_module requests}
BuildRequires: %{python_module xmlschema}
BuildRequires: lsof
BuildRequires: %{python_module numpy if (%python-base without python36-base)}
%endif
%if %{?python_version_nodots} < 36
Requires: python-pathlib2 >= 2.2.0
%endif
%python_subpackages
@ -114,7 +104,8 @@ sed -i '/^\[metadata\]/ a version = %{version}' setup.cfg
%check
%if %{with test}
%pytest
# assert rewrite: gh#pytest-dev/pytest#9761
%pytest -n auto -k "not (test_assertrewrite)"
%endif
%if ! %{with test}