15
0

- Add opensuse-test.patch making the tests work even with

versioned executables in the testing environment (i.e., before
  the alts scriptlets kick in).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-ansi2html?expand=0&rev=19
This commit is contained in:
2025-06-17 20:31:23 +00:00
committed by Git OBS Bridge
parent eb470ecfc7
commit 0851623132
3 changed files with 49 additions and 2 deletions

34
opensuse-test.patch Normal file
View File

@@ -0,0 +1,34 @@
---
tests/test_ansi2html.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: ansi2html-1.9.2/tests/test_ansi2html.py
===================================================================
--- ansi2html-1.9.2.orig/tests/test_ansi2html.py 2024-06-22 19:22:24.000000000 +0200
+++ ansi2html-1.9.2/tests/test_ansi2html.py 2025-06-17 22:27:11.354092953 +0200
@@ -50,6 +50,7 @@
class TestAnsi2HTML:
maxDiff = None
+ cmd_exe = "ansi2html-" + '.'.join([str(x) for x in sys.version_info[:2]])
def test_linkify(self) -> None:
ansi = "http://threebean.org#foobar"
@@ -465,7 +466,7 @@
assert target in html
def test_command_script(self) -> None:
- result = run(["ansi2html", "--version"], check=True)
+ result = run([self.cmd_exe, "--version"], check=True)
assert result.returncode == 0
def test_command_input_output_encoding(self) -> None:
@@ -480,7 +481,7 @@
with Popen(
[
- "ansi2html",
+ self.cmd_exe,
"--inline",
f"--input-encoding={input_encoding}",
f"--output-encoding={output_encoding}",

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jun 17 20:29:28 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Add opensuse-test.patch making the tests work even with
versioned executables in the testing environment (i.e., before
the alts scriptlets kick in).
-------------------------------------------------------------------
Mon Jun 16 12:20:51 UTC 2025 - Markéta Machová <mmachova@suse.com>

View File

@@ -26,6 +26,11 @@ License: LGPL-3.0-or-later
Group: Development/Languages/Python
URL: https://github.com/pycontribs/ansi2html/
Source: https://github.com/pycontribs/ansi2html/archive/v%{version}.tar.gz
# PATCH-FIX-OPENSUSE opensuse-test.patch bsc#[0-9]+ mcepl@suse.com
# Make tests work with versioned executables before alts kick in
# If any other test fails, because the executable is not
# "ansi2html", replace it with self.cmd_exe
Patch0: opensuse-test.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
@@ -45,7 +50,7 @@ Inspired by and developed off of the work of pixelbeat and blackjack.
Read the [docs](https://ansi2html.readthedocs.io/) for more informations.
%prep
%setup -q -n ansi2html-%{version}
%autosetup -p1 -n ansi2html-%{version}
%build
%pyproject_wheel
@@ -58,9 +63,10 @@ Read the [docs](https://ansi2html.readthedocs.io/) for more informations.
%check
# https://github.com/pycontribs/ansi2html/issues/169
sed -i 's:from mock:from unittest.mock:' tests/test_ansi2html.py
export PATH=$PATH:%{buildroot}%{_bindir}
# ansi2html not available (update alternatives); solvable
# but it runs just ansi2html --version
%pytest -k 'not test_command_script'
%pytest
%pre
%python_libalternatives_reset_alternative ansi2html