14
0
forked from pool/python-isort

- Add patch support-pytest-8.patch:

* Do not use the anti-pattern of pytest.warns(None).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-isort?expand=0&rev=117
This commit is contained in:
2024-08-30 02:58:04 +00:00
committed by Git OBS Bridge
parent 8483a72c7d
commit a6bb8329ae
3 changed files with 64 additions and 3 deletions

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Aug 30 02:57:29 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-pytest-8.patch:
* Do not use the anti-pattern of pytest.warns(None).
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Feb 27 08:59:27 UTC 2024 - Ben Greiner <code@bnavigator.de> Tue Feb 27 08:59:27 UTC 2024 - Ben Greiner <code@bnavigator.de>

View File

@@ -1,5 +1,5 @@
# #
# spec file # spec file for package python-isort
# #
# Copyright (c) 2024 SUSE LLC # Copyright (c) 2024 SUSE LLC
# #
@@ -40,13 +40,15 @@ License: MIT
URL: https://pycqa.github.io/isort/ URL: https://pycqa.github.io/isort/
# tests and example projects are not packaged for PyPI, get them from Github # tests and example projects are not packaged for PyPI, get them from Github
Source: https://github.com/PyCQA/isort/archive/%{version}.tar.gz#/isort-%{version}-gh.tar.gz Source: https://github.com/PyCQA/isort/archive/%{version}.tar.gz#/isort-%{version}-gh.tar.gz
# PATCH-FIX-UPSTREAM gh#PyCQA/isort#2235
Patch0: support-pytest-8.patch
BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module pip} BuildRequires: %{python_module pip}
BuildRequires: %{python_module poetry-core} BuildRequires: %{python_module poetry-core}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires(post): update-alternatives Requires(post): update-alternatives
Requires(postun):update-alternatives Requires(postun): update-alternatives
Recommends: python-colorama >= 0.4.3 Recommends: python-colorama >= 0.4.3
Recommends: python-pip-api Recommends: python-pip-api
Recommends: python-pip-shims >= 0.5.2 Recommends: python-pip-shims >= 0.5.2
@@ -58,6 +60,7 @@ BuildArch: noarch
BuildRequires: %{python_module black} BuildRequires: %{python_module black}
BuildRequires: %{python_module colorama >= 0.4.3} BuildRequires: %{python_module colorama >= 0.4.3}
BuildRequires: %{python_module hypothesmith} BuildRequires: %{python_module hypothesmith}
BuildRequires: %{python_module isort == %{version}}
BuildRequires: %{python_module libcst} BuildRequires: %{python_module libcst}
BuildRequires: %{python_module natsort} BuildRequires: %{python_module natsort}
BuildRequires: %{python_module numpy} BuildRequires: %{python_module numpy}
@@ -84,7 +87,7 @@ imports. It requires Python 3.8+ to run but supports formatting Python 2 code
too. too.
%prep %prep
%setup -q -n isort-%{version} %autosetup -p1 -n isort-%{version}
chmod -x LICENSE chmod -x LICENSE
%if %{without pylama} %if %{without pylama}

52
support-pytest-8.patch Normal file
View File

@@ -0,0 +1,52 @@
From 9c0b6272bfb1fd41298dd0fa9d072367bd79cc1b Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Thu, 15 Feb 2024 17:42:59 +0300
Subject: [PATCH] Drop deprecated pytest.warns(None)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
With Pytest 7:
https://docs.pytest.org/en/stable/changelog.html#pytest-7-0-0rc1-2021-12-06
> #8645: pytest.warns(None) is now deprecated because many people used
it to mean “this code does not emit warnings”, but it actually had the
effect of checking that the code emits at least one warning of any
type-like pytest.warns() or pytest.warns(Warning)
With Pytest 8 it's the error.
Changed according to the documentation:
https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests
Fixes: https://github.com/PyCQA/isort/issues/2234
Signed-off-by: Stanislav Levin <slev@altlinux.org>
---
tests/unit/test_ticketed_features.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/unit/test_ticketed_features.py b/tests/unit/test_ticketed_features.py
index 32eeb709..bc847ed5 100644
--- a/tests/unit/test_ticketed_features.py
+++ b/tests/unit/test_ticketed_features.py
@@ -3,6 +3,7 @@
"""
from functools import partial
from io import StringIO
+import warnings
import pytest
@@ -615,9 +616,9 @@ def test_isort_should_warn_on_empty_custom_config_issue_1433(tmpdir):
quiet = true
"""
)
- with pytest.warns(None) as warning: # type: ignore
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
assert Config(settings_file=str(settings_file)).quiet
- assert not warning
def test_float_to_top_should_respect_existing_newlines_between_imports_issue_1502():