Fix test failures with pytest 7.3.0

This commit is contained in:
Miro Hrončok 2023-04-12 16:37:58 +02:00
parent 8ca0bb339c
commit f540cdafa9
2 changed files with 33 additions and 1 deletions

24
pytest-7.3.patch Normal file
View File

@ -0,0 +1,24 @@
diff --git a/tests/test_arguments.py b/tests/test_arguments.py
index 735df4b..3395c55 100644
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -1,4 +1,5 @@
import sys
+from unittest import mock
import pytest
@@ -86,9 +87,12 @@ def test_bytes_args(runner, monkeypatch):
), "UTF-8 encoded argument should be implicitly converted to Unicode"
# Simulate empty locale environment variables
- monkeypatch.setattr(sys.stdin, "encoding", "utf-8")
monkeypatch.setattr(sys, "getfilesystemencoding", lambda: "utf-8")
monkeypatch.setattr(sys, "getdefaultencoding", lambda: "utf-8")
+ # sys.stdin.encoding is readonly, needs some extra effort to patch.
+ stdin = mock.Mock(wraps=sys.stdin)
+ stdin.encoding = "utf-8"
+ monkeypatch.setattr(sys, "stdin", stdin)
runner.invoke(
from_bytes,

View File

@ -2,12 +2,17 @@
Name: python-%{pypi_name}
Version: 8.1.3
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Simple wrapper around optparse for powerful command line utilities
License: BSD
URL: https://github.com/mitsuhiko/click
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
# Fix test failures with pytest 7.3.0
# From https://github.com/pallets/click/issues/2489#issuecomment-1504160617 by Ran Benita
Patch: pytest-7.3.patch
BuildArch: noarch
%global _description \
@ -49,6 +54,9 @@ sed -i 's|requirements/tests.txt|requirements/tests.in|' tox.ini
%doc README.rst CHANGES.rst
%changelog
* Wed Apr 12 2023 Miro Hrončok <mhroncok@redhat.com> - 8.1.3-3
- Fix test failures with pytest 7.3.0
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 8.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild