14
0

- Replace python-blockdiag-nose-to-pytest.patch with a different

upstream patch to also drop use of yield tests.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-blockdiag?expand=0&rev=30
This commit is contained in:
2025-08-27 02:56:11 +00:00
committed by Git OBS Bridge
parent f32c79236e
commit 6e06de1e4f
3 changed files with 140 additions and 24 deletions

View File

@@ -1,3 +1,15 @@
From 4f4f726252084f17ecc6c524592222af09d37da4 Mon Sep 17 00:00:00 2001
From: Guillaume Grossetie <ggrossetie@yuzutech.fr>
Date: Mon, 10 Jul 2023 00:31:37 +0200
Subject: [PATCH] Switch to pytest (nose is unmaintained and does not work on
Python3.10)
---
setup.py | 3 +-
src/blockdiag/tests/test_generate_diagram.py | 95 ++++++++++----------
tox.ini | 2 +-
3 files changed, 49 insertions(+), 51 deletions(-)
Index: blockdiag-3.0.0/setup.py Index: blockdiag-3.0.0/setup.py
=================================================================== ===================================================================
--- blockdiag-3.0.0.orig/setup.py --- blockdiag-3.0.0.orig/setup.py
@@ -23,39 +35,139 @@ Index: blockdiag-3.0.0/src/blockdiag/tests/test_generate_diagram.py
=================================================================== ===================================================================
--- blockdiag-3.0.0.orig/src/blockdiag/tests/test_generate_diagram.py --- blockdiag-3.0.0.orig/src/blockdiag/tests/test_generate_diagram.py
+++ blockdiag-3.0.0/src/blockdiag/tests/test_generate_diagram.py +++ blockdiag-3.0.0/src/blockdiag/tests/test_generate_diagram.py
@@ -19,8 +19,6 @@ import sys @@ -19,7 +19,7 @@ import sys
import unittest import unittest
from xml.etree import ElementTree from xml.etree import ElementTree
-from nose.tools import nottest -from nose.tools import nottest
- +import pytest
import blockdiag import blockdiag
import blockdiag.command import blockdiag.command
from blockdiag.tests.utils import (TemporaryDirectory, capture_stderr, @@ -38,7 +38,7 @@ def get_diagram_files(testdir):
@@ -52,7 +50,7 @@ def test_generate(): diagramsdir = os.path.join(testdir, 'diagrams')
files = get_diagram_files(basepath)
options = [] skipped = ['README', 'debian-logo-256color-palettealpha.png',
- 'errors', 'invalid.txt', 'white.gif']
+ 'errors', 'invalid.txt', 'white.gif', 'node_icon.diag']
for file in os.listdir(diagramsdir):
if file in skipped:
pass
@@ -46,66 +46,67 @@ def get_diagram_files(testdir):
yield os.path.join(diagramsdir, file)
-def test_generate():
- mainfunc = blockdiag.command.main
- basepath = os.path.dirname(__file__)
- files = get_diagram_files(basepath)
- options = []
+base_path = os.path.dirname(__file__)
+files = get_diagram_files(base_path)
+generate_testdata = []
+generate_with_separate_testdata = []
+for file_source in files:
+ generate_testdata.append((file_source, 'svg', []))
+ generate_testdata.append((file_source, 'png', []))
+ generate_testdata.append((file_source, 'png', ['--antialias']))
+ generate_testdata.append((file_source, 'pdf', []))
+ if re.search('separate', file_source):
+ generate_with_separate_testdata.append((file_source, 'svg', ['--separate']))
+ generate_with_separate_testdata.append((file_source, 'png', ['--separate']))
+ generate_with_separate_testdata.append((file_source, 'png', ['--separate', '--antialias']))
+ generate_with_separate_testdata.append((file_source, 'pdf', ['--separate']))
+
- for testcase in testcase_generator(basepath, mainfunc, files, options): - for testcase in testcase_generator(basepath, mainfunc, files, options):
+ for testcase in _testcase_generator(basepath, mainfunc, files, options): - yield testcase
yield testcase +@pytest.mark.parametrize("source,file_type,options", generate_with_separate_testdata)
+def test_generate_with_separate_option(source, file_type, options):
+ mainfunc = blockdiag.command.main
+ generate(mainfunc, source, file_type, options)
@@ -63,12 +61,11 @@ def test_generate_with_separate(): -def test_generate_with_separate():
filtered = (f for f in files if re.search('separate', f)) +@pytest.mark.parametrize("source,file_type,options", generate_testdata)
options = ['--separate'] +def test_generate_with_separate(source, file_type, options):
mainfunc = blockdiag.command.main
- basepath = os.path.dirname(__file__)
- files = get_diagram_files(basepath)
- filtered = (f for f in files if re.search('separate', f))
- options = ['--separate']
-
- for testcase in testcase_generator(basepath, mainfunc, filtered, options): - for testcase in testcase_generator(basepath, mainfunc, filtered, options):
+ for testcase in _testcase_generator(basepath, mainfunc, filtered, options): - yield testcase
yield testcase -
-
-@nottest -@nottest
-def testcase_generator(basepath, mainfunc, files, options): -def testcase_generator(basepath, mainfunc, files, options):
+def _testcase_generator(basepath, mainfunc, files, options): - fontpath = get_fontpath(basepath)
fontpath = get_fontpath(basepath) - options = options + ['-f', fontpath]
options = options + ['-f', fontpath] + generate(mainfunc, source, file_type, options)
- for source in files:
- yield generate, mainfunc, 'svg', source, options
+@capture_stderr
+def generate(mainfunc, source, file_type, options):
+ if file_type == 'png':
if not supported_pil():
- yield unittest.skip("Pillow is not available")(generate)
- yield unittest.skip("Pillow is not available")(generate)
- elif os.environ.get('ALL_TESTS') is None:
- message = "Skipped by default. To enable it, specify $ALL_TESTS=1"
- yield unittest.skip(message)(generate)
- yield unittest.skip(message)(generate)
- else:
- yield generate, mainfunc, 'png', source, options
- yield generate, mainfunc, 'png', source, options + ['--antialias']
-
+ unittest.skip('Pillow is not available')
+ return
+ if os.environ.get('ALL_TESTS') is None:
+ unittest.skip('Skipped by default. To enable it, specify $ALL_TESTS=1')
+ return
+ elif file_type == 'pdf':
if not supported_pdf():
- yield unittest.skip("reportlab is not available")(generate)
- elif os.environ.get('ALL_TESTS') is None:
- message = "Skipped by default. To enable it, specify $ALL_TESTS=1"
- yield unittest.skip(message)(generate)
- else:
- yield generate, mainfunc, 'pdf', source, options
-
+ unittest.skip('reportlab is not available')
+ return
+ if os.environ.get('ALL_TESTS') is None:
+ unittest.skip('Skipped by default. To enable it, specify $ALL_TESTS=1')
+ return
-@capture_stderr
-def generate(mainfunc, filetype, source, options):
+ tmpdir = None
try:
tmpdir = TemporaryDirectory()
- fd, tmpfile = tmpdir.mkstemp()
+ fd, tmp_file = tmpdir.mkstemp()
os.close(fd)
-
- mainfunc(['--debug', '-T', filetype, '-o', tmpfile, source] +
- list(options))
+ mainfunc(
+ [
+ '--debug',
+ '-T',
+ file_type,
+ '-o', tmp_file, source
+ ] + list(options)
+ )
finally:
- tmpdir.clean()
+ if tmpdir is not None:
+ tmpdir.clean()
def not_exist_font_config_option_test():
Index: blockdiag-3.0.0/tox.ini Index: blockdiag-3.0.0/tox.ini
=================================================================== ===================================================================
--- blockdiag-3.0.0.orig/tox.ini --- blockdiag-3.0.0.orig/tox.ini

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Aug 27 02:55:25 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Replace python-blockdiag-nose-to-pytest.patch with a different
upstream patch to also drop use of yield tests.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jun 4 14:58:34 UTC 2025 - Nico Krapp <nico.krapp@suse.com> Wed Jun 4 14:58:34 UTC 2025 - Nico Krapp <nico.krapp@suse.com>

View File

@@ -1,7 +1,7 @@
# #
# spec file for package python-blockdiag # spec file for package python-blockdiag
# #
# Copyright (c) 2025 SUSE LLC # Copyright (c) 2025 SUSE LLC and contributors
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@@ -23,11 +23,9 @@ Version: 3.0.0
Release: 0 Release: 0
Summary: Program to generate block-diagram images from text Summary: Program to generate block-diagram images from text
License: Apache-2.0 License: Apache-2.0
Group: Development/Languages/Python
URL: http://blockdiag.com/ URL: http://blockdiag.com/
Source: https://files.pythonhosted.org/packages/source/b/blockdiag/blockdiag-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/b/blockdiag/blockdiag-%{version}.tar.gz
# PATCH-FIX-UPSTREAM python-blockdiag-nose-to-pytest.patch gh#blockdiag/blockdiag#131 pgajdos@suse.com # PATCH-FIX-UPSTREAM Based on gh#blockdiag/blockdiag#175/commits/4f4f726252084f17ecc6c524592222af09d37da4
# Remove the last silly dependency on nose
Patch0: python-blockdiag-nose-to-pytest.patch Patch0: python-blockdiag-nose-to-pytest.patch
# PATCH-FIX-UPSTREAM https://github.com/blockdiag/blockdiag/pull/179 Add support for Pillow 10 # PATCH-FIX-UPSTREAM https://github.com/blockdiag/blockdiag/pull/179 Add support for Pillow 10
Patch1: pillow10.patch Patch1: pillow10.patch
@@ -94,6 +92,6 @@ popd
%doc CHANGES.rst README.rst %doc CHANGES.rst README.rst
%python_alternative %{_bindir}/blockdiag %python_alternative %{_bindir}/blockdiag
%{python_sitelib}/blockdiag %{python_sitelib}/blockdiag
%{python_sitelib}/blockdiag-%{version}*-info %{python_sitelib}/blockdiag-%{version}.dist-info
%changelog %changelog