From a6bb8329aed28b7798d8fe4b387b476d149fc49ad3f11bd8519f4927d5e9f09b Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Fri, 30 Aug 2024 02:58:04 +0000 Subject: [PATCH] - 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 --- python-isort.changes | 6 +++++ python-isort.spec | 9 +++++--- support-pytest-8.patch | 52 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 support-pytest-8.patch diff --git a/python-isort.changes b/python-isort.changes index c6411a7..96e1566 100644 --- a/python-isort.changes +++ b/python-isort.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Aug 30 02:57:29 UTC 2024 - Steve Kowalik + +- 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 diff --git a/python-isort.spec b/python-isort.spec index baf632b..600aa1d 100644 --- a/python-isort.spec +++ b/python-isort.spec @@ -1,5 +1,5 @@ # -# spec file +# spec file for package python-isort # # Copyright (c) 2024 SUSE LLC # @@ -40,13 +40,15 @@ License: MIT URL: https://pycqa.github.io/isort/ # 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 +# PATCH-FIX-UPSTREAM gh#PyCQA/isort#2235 +Patch0: support-pytest-8.patch BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module pip} BuildRequires: %{python_module poetry-core} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires(post): update-alternatives -Requires(postun):update-alternatives +Requires(postun): update-alternatives Recommends: python-colorama >= 0.4.3 Recommends: python-pip-api Recommends: python-pip-shims >= 0.5.2 @@ -58,6 +60,7 @@ BuildArch: noarch BuildRequires: %{python_module black} BuildRequires: %{python_module colorama >= 0.4.3} BuildRequires: %{python_module hypothesmith} +BuildRequires: %{python_module isort == %{version}} BuildRequires: %{python_module libcst} BuildRequires: %{python_module natsort} BuildRequires: %{python_module numpy} @@ -84,7 +87,7 @@ imports. It requires Python 3.8+ to run but supports formatting Python 2 code too. %prep -%setup -q -n isort-%{version} +%autosetup -p1 -n isort-%{version} chmod -x LICENSE %if %{without pylama} diff --git a/support-pytest-8.patch b/support-pytest-8.patch new file mode 100644 index 0000000..5e201c5 --- /dev/null +++ b/support-pytest-8.patch @@ -0,0 +1,52 @@ +From 9c0b6272bfb1fd41298dd0fa9d072367bd79cc1b Mon Sep 17 00:00:00 2001 +From: Stanislav Levin +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 +--- + 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():