From 83a97a4a33f428985063ce7a917ed54096220dbaba3c16930f7c0a835398d912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Thu, 12 Jun 2025 12:42:17 +0000 Subject: [PATCH] - Convert to pip-based build OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinxcontrib-blockdiag?expand=0&rev=17 --- .gitattributes | 23 + .gitignore | 1 + 25.patch | 1554 +++++++++++++++++++ _multibuild | 3 + python-sphinxcontrib-blockdiag-3.0.0.tar.gz | 3 + python-sphinxcontrib-blockdiag.changes | 62 + python-sphinxcontrib-blockdiag.spec | 87 ++ remove-mock.patch | 12 + 8 files changed, 1745 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 25.patch create mode 100644 _multibuild create mode 100644 python-sphinxcontrib-blockdiag-3.0.0.tar.gz create mode 100644 python-sphinxcontrib-blockdiag.changes create mode 100644 python-sphinxcontrib-blockdiag.spec create mode 100644 remove-mock.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/25.patch b/25.patch new file mode 100644 index 0000000..146f582 --- /dev/null +++ b/25.patch @@ -0,0 +1,1554 @@ +From 2652a28bcc853e0aa20f91cbce3967a6afacecce Mon Sep 17 00:00:00 2001 +From: Daniel Garcia Moreno +Date: Thu, 29 Sep 2022 12:16:42 +0200 +Subject: [PATCH] Remove sphinx-testing from test suite + +This patch uses pytest for testing and replaces the sphinx_testing +package with the default sphinx.testing. + +Fix https://github.com/blockdiag/sphinxcontrib-blockdiag/issues/23 +--- + tests/conftest.py | 1 + + tests/docs/basic/index.rst | 9 +- + tests/docs/subdir/index.rst | 8 +- + tests/test_basic.py | 16 +- + tests/test_errors.py | 116 +++-- + tests/test_html.py | 858 +++++++++++++++++++----------------- + tests/test_latex.py | 396 +++++++++-------- + tox.ini | 13 +- + 8 files changed, 756 insertions(+), 661 deletions(-) + create mode 100644 tests/conftest.py + +diff --git a/tests/conftest.py b/tests/conftest.py +new file mode 100644 +index 0000000..1ece6b4 +--- /dev/null ++++ b/tests/conftest.py +@@ -0,0 +1 @@ ++pytest_plugins = 'sphinx.testing.fixtures' +diff --git a/tests/docs/basic/index.rst b/tests/docs/basic/index.rst +index 819e556..8a5a97d 100644 +--- a/tests/docs/basic/index.rst ++++ b/tests/docs/basic/index.rst +@@ -1,9 +1,6 @@ +-Welcome to test's documentation! +-================================ + + .. blockdiag:: + +- { +- A -> B; +- } +- ++ A -> B; ++ A [href = ':ref:`target`']; ++ +\ No newline at end of file +diff --git a/tests/docs/subdir/index.rst b/tests/docs/subdir/index.rst +index 819e556..ba6f8b1 100644 +--- a/tests/docs/subdir/index.rst ++++ b/tests/docs/subdir/index.rst +@@ -1,9 +1,5 @@ +-Welcome to test's documentation! +-================================ + + .. blockdiag:: + +- { +- A -> B; +- } +- ++ A -> B; ++ +\ No newline at end of file +diff --git a/tests/test_basic.py b/tests/test_basic.py +index 0bba91e..c982904 100644 +--- a/tests/test_basic.py ++++ b/tests/test_basic.py +@@ -1,28 +1,32 @@ + # -*- coding: utf-8 -*- + +-from sphinx_testing import with_app ++import os ++import pytest + + +-@with_app(buildername='html', srcdir='tests/docs/basic/') ++docs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs', 'basic') ++ ++ ++@pytest.mark.sphinx(buildername='html', srcdir=docs) + def test_build_html(app, status, warning): + app.builder.build_all() + + +-@with_app(buildername='singlehtml', srcdir='tests/docs/basic/') ++@pytest.mark.sphinx(buildername='singlehtml', srcdir=docs) + def test_build_singlehtml(app, status, warning): + app.builder.build_all() + + +-@with_app(buildername='latex', srcdir='tests/docs/basic/') ++@pytest.mark.sphinx(buildername='latex', srcdir=docs) + def test_build_latex(app, status, warning): + app.builder.build_all() + + +-@with_app(buildername='epub', srcdir='tests/docs/basic/') ++@pytest.mark.sphinx(buildername='epub', srcdir=docs) + def test_build_epub(app, status, warning): + app.builder.build_all() + + +-@with_app(buildername='json', srcdir='tests/docs/basic/') ++@pytest.mark.sphinx(buildername='json', srcdir=docs) + def test_build_json(app, status, warning): + app.builder.build_all() +diff --git a/tests/test_errors.py b/tests/test_errors.py +index 8a6a89a..58bc67c 100644 +--- a/tests/test_errors.py ++++ b/tests/test_errors.py +@@ -1,54 +1,84 @@ + # -*- coding: utf-8 -*- + + from mock import patch +-from sphinx_testing import with_app + ++import os + import sys +-import unittest ++import pytest + + +-class TestSphinxcontribBlockdiagErrors(unittest.TestCase): +- @with_app(srcdir='tests/docs/basic', write_docstring=True) +- def test_parse_error(self, app, status, warning): +- """ +- .. blockdiag:: ++docs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs', 'basic') + +- { A -> B; +- """ +- app.builder.build_all() +- self.assertIn('got unexpected token:', warning.getvalue()) + +- @with_app(srcdir='tests/docs/basic', confoverrides=dict(blockdiag_html_image_format='JPG')) +- def test_unknown_format_error(self, app, status, warning): +- app.builder.build_all() +- self.assertIn('unknown format: JPG', warning.getvalue()) +- +- @with_app(srcdir='tests/docs/basic', confoverrides=dict(blockdiag_html_image_format='PDF')) +- def test_reportlab_not_found_error(self, app, status, warning): +- try: +- # unload reportlab and make loading it impossible +- sys.modules.pop('reportlab', None) +- path = sys.path +- sys.path = [] +- +- app.builder.build_all() +- +- self.assertIn('Could not output PDF format. Install reportlab.', +- warning.getvalue()) +- finally: +- sys.path = path +- +- @with_app(srcdir='tests/docs/basic') +- @patch("blockdiag.utils.rst.nodes.blockdiag.processor.drawer.DiagramDraw") +- def test_rendering_error(self, app, status, warning, DiagramDraw): +- DiagramDraw.side_effect = RuntimeError("UNKNOWN ERROR!") +- app.builder.build_all() +- self.assertIn('UNKNOWN ERROR!', warning.getvalue()) ++@pytest.mark.sphinx(srcdir=docs) ++def test_parse_error(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ { A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ assert 'got unexpected token:' in warning.getvalue() ++ ++ ++@pytest.mark.sphinx(srcdir=docs, confoverrides=dict(blockdiag_html_image_format='JPG')) ++def test_unknown_format_error(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ assert 'unknown format: JPG' in warning.getvalue() ++ ++ ++@pytest.mark.sphinx(srcdir=docs, confoverrides=dict(blockdiag_html_image_format='PDF')) ++def test_reportlab_not_found_error(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ try: ++ # unload reportlab and make loading it impossible ++ sys.modules.pop('reportlab', None) ++ path = sys.path ++ sys.path = [] + +- @with_app(srcdir='tests/docs/basic') +- @patch("sphinxcontrib.blockdiag.blockdiag.drawer.DiagramDraw.draw") +- def test_font_settings_error(self, app, status, warning, draw): +- draw.side_effect = UnicodeEncodeError("", "", 0, 0, "") + app.builder.build_all() +- self.assertIn('UnicodeEncodeError caught (check your font settings)', +- warning.getvalue()) ++ ++ assert 'Could not output PDF format. Install reportlab.' in warning.getvalue() ++ finally: ++ sys.path = path ++ ++ ++@pytest.mark.sphinx(srcdir=docs) ++@patch("blockdiag.utils.rst.nodes.blockdiag.processor.drawer.DiagramDraw") ++def test_rendering_error(DiagramDraw, app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ DiagramDraw.side_effect = RuntimeError("UNKNOWN ERROR!") ++ app.builder.build_all() ++ assert 'UNKNOWN ERROR!' in warning.getvalue() ++ ++ ++@pytest.mark.skipif(sys.version_info > (3, 8), reason="Failsonpython > 3.8") ++@pytest.mark.sphinx(srcdir=docs) ++@patch("sphinxcontrib.blockdiag.blockdiag.drawer.DiagramDraw.draw") ++def test_font_settings_error(draw, app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ draw.side_effect = UnicodeEncodeError("", "", 0, 0, "") ++ app.builder.build_all() ++ assert 'UnicodeEncodeError caught (check your font settings)' in warning.getvalue() +diff --git a/tests/test_html.py b/tests/test_html.py +index aa530ea..1a953f0 100644 +--- a/tests/test_html.py ++++ b/tests/test_html.py +@@ -1,405 +1,457 @@ + # -*- coding: utf-8 -*- + +-from sphinx_testing import with_app +- +-import unittest +- +- +-with_png_app = with_app(srcdir='tests/docs/basic', +- buildername='html', +- write_docstring=True) +-with_svg_app = with_app(srcdir='tests/docs/basic', +- buildername='html', +- write_docstring=True, +- confoverrides={ +- 'blockdiag_html_image_format': 'SVG' +- }) +- +- +-class TestSphinxcontribBlockdiagHTML(unittest.TestCase): +- @with_png_app +- def test_build_png_image(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_app(srcdir='tests/docs/subdir', buildername='html', write_docstring=True) +- def test_build_png_image_in_subdir(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'subdir' / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'
') +- +- @with_png_app +- def test_width_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 224 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_height_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :height: 240 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_width_option_and_height_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 100 +- :height: 200 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text() +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_scale_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :scale: 25% +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_width_option_and_scale_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 28 +- :scale: 25% +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_align_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: center +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_png_app +- def test_align_option_and_width_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: center +- :width: 224 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_name_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :name: target +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_png_app +- def test_name_option_and_width_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :name: target +- :width: 224 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_href_and_scale_option_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- :scale: 50% +- +- A -> B; +- A [href = 'http://blockdiag.com/']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('')) +- +- @with_png_app +- def test_reftarget_in_href_on_png1(self, app, status, warning): +- """ +- .. _target: +- +- heading2 +- --------- +- +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`target`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_reftarget_in_href_on_png2(self, app, status, warning): +- """ +- .. _hello world: +- +- heading2 +- --------- +- +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`hello world`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '' +- '
')) +- +- @with_png_app +- def test_missing_reftarget_in_href_on_png(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`unknown_target`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
')) +- self.assertIn('undefined label: unknown_target', warning.getvalue()) +- +- @with_app(srcdir='tests/docs/basic', copy_srcdir_to_tmpdir=True, +- write_docstring=True, confoverrides={'blockdiag_html_image_format': 'SVG'}) +- def test_build_svg_image(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_svg_app +- def test_width_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 224 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '')) +- +- @with_svg_app +- def test_height_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :height: 240 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '')) +- +- @with_svg_app +- def test_width_option_and_height_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 100 +- :height: 200 +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '')) +- +- @with_svg_app +- def test_scale_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :scale: 25% +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '')) +- +- @with_svg_app +- def test_width_option_and_scale_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 28 +- :scale: 25% +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ('
' +- '')) +- +- @with_svg_app +- def test_align_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: center +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_svg_app +- def test_name_option_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- :name: target +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '
') +- +- @with_svg_app +- def test_reftarget_in_href_on_svg1(self, app, status, warning): +- """ +- .. _target: +- +- heading2 +- --------- +- +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`target`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '\\n\\s*\\n\\s*') +- +- @with_svg_app +- def test_reftarget_in_href_on_svg2(self, app, status, warning): +- """ +- .. _hello world: +- +- heading2 +- --------- +- +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`hello world`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, '\\n\\s*\\n\\s*') +- +- @with_svg_app +- def test_missing_reftarget_in_href_on_svg(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`unknown_target`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertNotRegex(source, '\\n\\s*\\n\\s*') +- self.assertIn('undefined label: unknown_target', warning.getvalue()) +- +- @with_svg_app +- def test_autoclass_should_not_effect_to_other_diagram(self, app, status, warning): +- """ +- This testcase checks that autoclass plugin is unloaded correctly (and it does not effect to other diagram). +- +- .. blockdiag:: +- +- plugin autoclass; +- class foo [color = red]; +- A_foo; +- +- .. blockdiag:: +- +- class foo [color = red]; +- A_foo; +- """ +- app.builder.build_all() +- source = (app.outdir / 'index.html').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, ']+>A_foo') # 2nd diagram has a node labeled 'A_foo'. ++import re ++import os ++import pytest ++ ++ ++docs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs', 'basic') ++subdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs', 'subdir') ++ ++ ++with_png_app = pytest.mark.sphinx(srcdir=docs, buildername='html') ++with_svg_app = pytest.mark.sphinx(srcdir=docs, ++ buildername='html', ++ confoverrides={ ++ 'blockdiag_html_image_format': 'SVG' ++ }) ++ ++ ++@with_png_app ++def test_build_png_image(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@pytest.mark.sphinx(srcdir=subdir, buildername='html') ++def test_build_png_image_in_subdir(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'subdir' / 'index.html').read_text(encoding='utf-8') ++ assert re.search(r'
', source) ++ ++ ++@with_png_app ++def test_width_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 224 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_height_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :height: 240 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_width_option_and_height_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 100 ++ :height: 200 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text() ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_scale_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :scale: 25% ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_width_option_and_scale_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 28 ++ :scale: 25% ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_align_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: center ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@with_png_app ++def test_align_option_and_width_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: center ++ :width: 224 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_name_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :name: target ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@with_png_app ++def test_name_option_and_width_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :name: target ++ :width: 224 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_href_and_scale_option_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :scale: 50% ++ ++ A -> B; ++ A [href = 'http://blockdiag.com/']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search((''), source) ++ ++ ++@with_png_app ++def test_reftarget_in_href_on_png1(app, status, warning): ++ doc = """ ++.. _target: ++ ++heading2 ++--------- ++ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`target`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_reftarget_in_href_on_png2(app, status, warning): ++ doc = """ ++.. _hello world: ++ ++heading2 ++--------- ++ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`hello world`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ '' ++ '
'), source) ++ ++ ++@with_png_app ++def test_missing_reftarget_in_href_on_png(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`unknown_target`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ assert 'undefined label: unknown_target' in warning.getvalue() ++ ++ ++@pytest.mark.sphinx(srcdir=docs, confoverrides={'blockdiag_html_image_format': 'SVG'}) ++def test_build_svg_image(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@with_svg_app ++def test_width_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 224 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ ''), source) ++ ++ ++@with_svg_app ++def test_height_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :height: 240 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ ''), source) ++ ++ ++@with_svg_app ++def test_width_option_and_height_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 100 ++ :height: 200 ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ ''), source) ++ ++ ++@with_svg_app ++def test_scale_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :scale: 25% ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ ''), source) ++ ++ ++@with_svg_app ++def test_width_option_and_scale_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 28 ++ :scale: 25% ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(('
' ++ ''), source) ++ ++ ++@with_svg_app ++def test_align_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: center ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@with_svg_app ++def test_name_option_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :name: target ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('
', source) ++ ++ ++@with_svg_app ++def test_reftarget_in_href_on_svg1(app, status, warning): ++ doc = """ ++.. _target: ++ ++heading2 ++--------- ++ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`target`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('\\n\\s*\\n\\s*', source) ++ ++ ++@with_svg_app ++def test_reftarget_in_href_on_svg2(app, status, warning): ++ doc = """ ++.. _hello world: ++ ++heading2 ++--------- ++ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`hello world`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search('\\n\\s*\\n\\s*', source) ++ ++ ++@with_svg_app ++def test_missing_reftarget_in_href_on_svg(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`unknown_target`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert not re.search('\\n\\s*\\n\\s*', source) ++ assert 'undefined label: unknown_target' in warning.getvalue() ++ ++ ++@with_svg_app ++def test_autoclass_should_not_effect_to_other_diagram(app, status, warning): ++ doc = """ ++This testcase checks that autoclass plugin is unloaded correctly (and it does not effect to other diagram). ++ ++.. blockdiag:: ++ ++ plugin autoclass; ++ class foo [color = red]; ++ A_foo; ++ ++.. blockdiag:: ++ ++ class foo [color = red]; ++ A_foo; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'index.html').read_text(encoding='utf-8') ++ assert re.search(']+>A_foo', source) # 2nd diagram has a node labeled 'A_foo'. +diff --git a/tests/test_latex.py b/tests/test_latex.py +index bcef06f..82c49a9 100644 +--- a/tests/test_latex.py ++++ b/tests/test_latex.py +@@ -2,198 +2,216 @@ + + import os + import re +-from sphinx_testing import with_app + + import unittest ++import pytest ++ ++docs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs', 'basic') + + CR = "\r?\n" + + blockdiag_fontpath = '/usr/share/fonts/truetype/ipafont/ipagp.ttf' +-with_png_app = with_app(srcdir='tests/docs/basic', +- buildername='latex', +- write_docstring=True, +- confoverrides={ +- 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], +- }) +-with_pdf_app = with_app(srcdir='tests/docs/basic', +- buildername='latex', +- write_docstring=True, +- confoverrides={ +- 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], +- 'blockdiag_latex_image_format': 'PDF', +- 'blockdiag_fontpath': blockdiag_fontpath, +- }) +-with_oldpdf_app = with_app(srcdir='tests/docs/basic', +- buildername='latex', +- write_docstring=True, +- confoverrides={ +- 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], +- 'blockdiag_tex_image_format': 'PDF', +- 'blockdiag_fontpath': blockdiag_fontpath, +- }) +- +- +-class TestSphinxcontribBlockdiagLatex(unittest.TestCase): +- @with_png_app +- def test_build_png_image(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics{{blockdiag-.*?}.png}') +- +- @unittest.skipUnless(os.path.exists(blockdiag_fontpath), "TrueType font not found") +- @with_pdf_app +- def test_build_pdf_image1(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics{{blockdiag-.*?}.pdf}') +- +- @unittest.skipUnless(os.path.exists(blockdiag_fontpath), "TrueType font not found") +- @with_oldpdf_app +- def test_build_pdf_image2(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics{{blockdiag-.*?}.pdf}') +- +- @with_png_app +- def test_width_option(self, app, status, warning): +- """ +- .. blockdiag:: +- :width: 3cm +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics\[width=3cm\]{{blockdiag-.*?}.png}') +- +- @with_png_app +- def test_height_option(self, app, status, warning): +- """ +- .. blockdiag:: +- :height: 4cm +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics\[height=4cm\]{{blockdiag-.*?}.png}') +- +- @with_png_app +- def test_scale_option(self, app, status, warning): +- """ +- .. blockdiag:: +- :scale: 50% +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics\[scale=0.5\]{{blockdiag-.*?}.png}') +- +- @with_png_app +- def test_align_option_left(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: left +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, +- (r'{\\sphinxincludegraphics{{blockdiag-.*?}.png}' +- r'\\hspace\*{\\fill}}')) +- +- @with_png_app +- def test_align_option_center(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: center +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, +- (r'{\\hspace\*{\\fill}' +- r'\\sphinxincludegraphics{{blockdiag-.*?}.png}' +- r'\\hspace\*{\\fill}}')) +- +- @with_png_app +- def test_align_option_right(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: right +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, +- (r'{\\hspace\*{\\fill}' +- r'\\sphinxincludegraphics{{blockdiag-.*?}.png}}')) +- +- @with_png_app +- def test_caption_option(self, app, status, warning): +- """ +- .. blockdiag:: +- :caption: hello world +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- +- figure = re.compile((r'\\begin{figure}\[htbp\]' + CR + +- r'\\centering' + CR + +- r'\\capstart' + CR + CR + +- r'\\noindent\\sphinxincludegraphics{{blockdiag-.*?}.png}' + CR + +- r'\\caption{hello world}\\label{\\detokenize{index:id1}}\\end{figure}'), +- re.DOTALL) +- self.assertRegexpMatches(source, figure) +- +- @with_png_app +- def test_caption_option_and_align_option(self, app, status, warning): +- """ +- .. blockdiag:: +- :align: left +- :caption: hello world +- +- A -> B; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- +- figure = re.compile((r'\\begin{wrapfigure}{l}{0pt}' + CR + +- r'\\centering' + CR + +- r'\\noindent\\sphinxincludegraphics{{blockdiag-.*?}.png}' + CR + +- r'\\caption{hello world}\\label{\\detokenize{index:id1}}\\end{wrapfigure}'), +- re.DOTALL) +- self.assertRegexpMatches(source, figure) +- +- @with_png_app +- def test_href(self, app, status, warning): +- """ +- .. blockdiag:: +- +- A -> B; +- A [href = ':ref:`target`']; +- """ +- app.builder.build_all() +- source = (app.outdir / 'test.tex').read_text(encoding='utf-8') +- self.assertRegexpMatches(source, r'\\sphinxincludegraphics{{blockdiag-.*?}.png}') ++with_png_app = pytest.mark.sphinx(srcdir=docs, ++ buildername='latex', ++ confoverrides={ ++ 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], ++ }) ++with_pdf_app = pytest.mark.sphinx(srcdir=docs, ++ buildername='latex', ++ confoverrides={ ++ 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], ++ 'blockdiag_latex_image_format': 'PDF', ++ 'blockdiag_fontpath': blockdiag_fontpath, ++ }) ++with_oldpdf_app = pytest.mark.sphinx(srcdir=docs, ++ buildername='latex', ++ confoverrides={ ++ 'latex_documents': [('index', 'test.tex', '', 'test', 'manual')], ++ 'blockdiag_tex_image_format': 'PDF', ++ 'blockdiag_fontpath': blockdiag_fontpath, ++ }) ++ ++ ++@with_png_app ++def test_build_png_image(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics{{blockdiag-.*?}.png}', source) ++ ++ ++@unittest.skipUnless(os.path.exists(blockdiag_fontpath), "TrueType font not found") ++@with_pdf_app ++def test_build_pdf_image1(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics{{blockdiag-.*?}.pdf}', source) ++ ++ ++@unittest.skipUnless(os.path.exists(blockdiag_fontpath), "TrueType font not found") ++@with_oldpdf_app ++def test_build_pdf_image2(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics{{blockdiag-.*?}.pdf}', source) ++ ++ ++@with_png_app ++def test_width_option(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :width: 3cm ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics\[width=3cm\]{{blockdiag-.*?}.png}', source) ++ ++ ++@with_png_app ++def test_height_option(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :height: 4cm ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics\[height=4cm\]{{blockdiag-.*?}.png}', source) ++ ++ ++@with_png_app ++def test_scale_option(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :scale: 50% ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics\[scale=0.5\]{{blockdiag-.*?}.png}', source) ++ ++ ++@with_png_app ++def test_align_option_left(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: left ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search((r'{\\sphinxincludegraphics{{blockdiag-.*?}.png}' ++ r'\\hspace\*{\\fill}}'), source) ++ ++ ++@with_png_app ++def test_align_option_center(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: center ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search((r'{\\hspace\*{\\fill}' ++ r'\\sphinxincludegraphics{{blockdiag-.*?}.png}' ++ r'\\hspace\*{\\fill}}'), source) ++ ++ ++@with_png_app ++def test_align_option_right(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: right ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search((r'{\\hspace\*{\\fill}' ++ r'\\sphinxincludegraphics{{blockdiag-.*?}.png}}'), source) ++ ++ ++@with_png_app ++def test_caption_option(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :caption: hello world ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ ++ figure = re.compile((r'\\begin{figure}\[htbp\]' + CR + ++ r'\\centering' + CR + ++ r'\\capstart' + CR + CR + ++ r'\\noindent\\sphinxincludegraphics{{blockdiag-.*?}.png}' + CR + ++ r'\\caption{hello world}\\label{\\detokenize{index:id1}}\\end{figure}'), ++ re.DOTALL) ++ assert re.search(figure, source) ++ ++ ++@with_png_app ++def test_caption_option_and_align_option(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ :align: left ++ :caption: hello world ++ ++ A -> B; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ ++ figure = re.compile((r'\\begin{wrapfigure}{l}{0pt}' + CR + ++ r'\\centering' + CR + ++ r'\\noindent\\sphinxincludegraphics{{blockdiag-.*?}.png}' + CR + ++ r'\\caption{hello world}\\label{\\detokenize{index:id1}}\\end{wrapfigure}'), ++ re.DOTALL) ++ assert re.search(figure, source) ++ ++ ++@with_png_app ++def test_href(app, status, warning): ++ doc = """ ++.. blockdiag:: ++ ++ A -> B; ++ A [href = ':ref:`target`']; ++ """ ++ (app.srcdir / 'index.rst').write_text(doc, encoding='utf-8') ++ app.builder.build_all() ++ source = (app.outdir / 'test.tex').read_text(encoding='utf-8') ++ assert re.search(r'\\sphinxincludegraphics{{blockdiag-.*?}.png}', source) +diff --git a/tox.ini b/tox.ini +index 759e174..430f652 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -5,22 +5,21 @@ + ## building sphinx docs in separate virtual environments. Give it a try! + + [tox] +-envlist = py{37,38,39},blockdiag_dev ++envlist = py{37,38,39,310},blockdiag_dev + + [testenv] + usedevelop = True + deps= +- nose ++ pytest + mock + flake8 + reportlab +- sphinx-testing >= 0.5.2 + # for funcparserlib-1.0.0a0 + pip_pre=true + passenv= + TRAVIS* + commands= +- nosetests ++ pytest + flake8 setup.py sphinxcontrib/ tests/ + + [testenv:blockdiag_dev] +@@ -31,8 +30,6 @@ deps= + [testenv:coverage] + deps= + {[testenv]deps} +- coverage +- coveralls ++ pytest-cov + commands= +- nosetests --with-coverage --cover-package=sphinxcontrib +- coveralls ++ pytest -vv --cov=sphinxcontrib diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/python-sphinxcontrib-blockdiag-3.0.0.tar.gz b/python-sphinxcontrib-blockdiag-3.0.0.tar.gz new file mode 100644 index 0000000..9dcdee1 --- /dev/null +++ b/python-sphinxcontrib-blockdiag-3.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9061847004d900b458c2d611b4b539b2a3d594648060a222959f49c837cb41dc +size 12300 diff --git a/python-sphinxcontrib-blockdiag.changes b/python-sphinxcontrib-blockdiag.changes new file mode 100644 index 0000000..75d4a4c --- /dev/null +++ b/python-sphinxcontrib-blockdiag.changes @@ -0,0 +1,62 @@ +------------------------------------------------------------------- +Thu Jun 12 12:41:59 UTC 2025 - Markéta Machová + +- Convert to pip-based build + +------------------------------------------------------------------- +Mon Oct 10 06:32:23 UTC 2022 - Steve Kowalik + +- Add patch remove-mock.patch. + +------------------------------------------------------------------- +Thu Sep 29 10:26:09 UTC 2022 - Daniel Garcia + +- Add multibuild to run tests +- Use the github source because the pypi doesn't have the tests +- Add patch 25.patch to remove the sphinx-testing dependency + +------------------------------------------------------------------- +Mon Jan 10 22:28:47 UTC 2022 - Dirk Müller + +- update to 3.0.0: + * drop python 3.5/3.6 support + * add python 3.9+ support + +------------------------------------------------------------------- +Mon Feb 24 15:09:15 UTC 2020 - Ondřej Súkup + +- update to 2.0.0 +- drop py2 support + +------------------------------------------------------------------- +Fri Dec 14 12:17:54 UTC 2018 - Matěj Cepl + +- Package should own whole sitelib/sphinxcontrib/__pycache__ + +------------------------------------------------------------------- +Fri Dec 7 21:04:16 UTC 2018 - Matej Cepl + +- Remove wrong BR on python-sphinxcontrib + +------------------------------------------------------------------- +Tue Dec 4 12:54:39 UTC 2018 - Matej Cepl + +- Remove superfluous devel dependency for noarch package + +------------------------------------------------------------------- +Mon Sep 18 22:29:06 UTC 2017 - toddrme2178@gmail.com + +- Use new python-sphinxcontrib package to provide namespace + directory. + +------------------------------------------------------------------- +Mon Sep 18 20:36:57 UTC 2017 - toddrme2178@gmail.com + +- Specify files to guarantee namespace package doesn't conflict + with python(2|3)-Sphinx + +------------------------------------------------------------------- +Mon Oct 31 20:20:42 UTC 2016 - termim@gmail.com + +- initial checkin version 1.5.5 + diff --git a/python-sphinxcontrib-blockdiag.spec b/python-sphinxcontrib-blockdiag.spec new file mode 100644 index 0000000..bb053b6 --- /dev/null +++ b/python-sphinxcontrib-blockdiag.spec @@ -0,0 +1,87 @@ +# +# spec file for package python-sphinxcontrib-blockdiag +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +%bcond_with test +Name: python-sphinxcontrib-blockdiag +Version: 3.0.0 +Release: 0 +Summary: Sphinx "blockdiag" extension +License: BSD-2-Clause +URL: https://github.com/blockdiag/sphinxcontrib-blockdiag +# Use the github tag instead of the pythonhosted.org to get the tests folder +Source: https://github.com/blockdiag/sphinxcontrib-blockdiag/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz +# PATCH-FEATURE-UPSTREAM 25.patch gh#blockdiag/sphinxcontrib-blockdiag#25 +Patch0: https://patch-diff.githubusercontent.com/raw/blockdiag/sphinxcontrib-blockdiag/pull/25.patch +Patch1: remove-mock.patch +BuildRequires: %{python_module Sphinx >= 2.0} +BuildRequires: %{python_module blockdiag >= 1.5.0} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: python-Sphinx >= 2.0 +Requires: python-blockdiag >= 1.5.0 +BuildArch: noarch +%if %{with test} +BuildRequires: %{python_module Sphinx-latex} +BuildRequires: %{python_module funcparserlib} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module sphinxcontrib-blockdiag = %{version}} +%endif +%python_subpackages + +%description +A sphinx extension for embedding block diagram using blockdiag. + +%prep +%autosetup -p1 -n sphinxcontrib-blockdiag-%{version} + +%build +%pyproject_wheel + +%install +%if !%{with test} +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif + +%if %{with test} +%check +%pytest +%endif + +%if !%{with test} +%files %{python_files} +%license LICENSE +%doc AUTHORS README.rst +%{python_sitelib}/sphinxcontrib/blockdiag.py* +%pycache_only %{python_sitelib}/sphinxcontrib/__pycache__ +%{python_sitelib}/sphinxcontrib_blockdiag-%{version}-py*-nspkg.pth +%{python_sitelib}/sphinxcontrib_blockdiag-%{version}*-info +%endif + +%changelog diff --git a/remove-mock.patch b/remove-mock.patch new file mode 100644 index 0000000..918b7af --- /dev/null +++ b/remove-mock.patch @@ -0,0 +1,12 @@ +Index: sphinxcontrib-blockdiag-3.0.0/tests/test_errors.py +=================================================================== +--- sphinxcontrib-blockdiag-3.0.0.orig/tests/test_errors.py ++++ sphinxcontrib-blockdiag-3.0.0/tests/test_errors.py +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + +-from mock import patch ++from unittest.mock import patch + + import os + import sys