From 5bb0bb4be543fd5eca41673696a62ed80d493591 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 5 Jun 2024 18:20:58 +0200 Subject: Adding upstream version 7.3.7. Signed-off-by: Daniel Baumann --- tests/test_extensions/test_ext_autosectionlabel.py | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/test_extensions/test_ext_autosectionlabel.py (limited to 'tests/test_extensions/test_ext_autosectionlabel.py') diff --git a/tests/test_extensions/test_ext_autosectionlabel.py b/tests/test_extensions/test_ext_autosectionlabel.py new file mode 100644 index 0000000..f854ecf --- /dev/null +++ b/tests/test_extensions/test_ext_autosectionlabel.py @@ -0,0 +1,77 @@ +"""Test sphinx.ext.autosectionlabel extension.""" + +import re + +import pytest + + +@pytest.mark.sphinx('html', testroot='ext-autosectionlabel') +def test_autosectionlabel_html(app, status, warning, skipped_labels=False): + app.build(force_all=True) + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + html = ('
  • ' + 'Introduce of Sphinx

  • ') + assert re.search(html, content, re.DOTALL) + + html = ('
  • ' + 'Installation

  • ') + assert re.search(html, content, re.DOTALL) + + html = ('
  • ' + 'For Windows users

  • ') + assert re.search(html, content, re.DOTALL) + + html = ('
  • ' + 'For UNIX users

  • ') + assert re.search(html, content, re.DOTALL) + + html = ('
  • ' + 'Linux

  • ') + assert re.search(html, content, re.DOTALL) + + html = ('
  • ' + 'FreeBSD

  • ') + assert re.search(html, content, re.DOTALL) + + # for smart_quotes (refs: #4027) + html = ('
  • ' + 'This one’s got an apostrophe' + '

  • ') + assert re.search(html, content, re.DOTALL) + + +# Reuse test definition from above, just change the test root directory +@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document') +def test_autosectionlabel_prefix_document_html(app, status, warning): + test_autosectionlabel_html(app, status, warning) + + +@pytest.mark.sphinx('html', testroot='ext-autosectionlabel', + confoverrides={'autosectionlabel_maxdepth': 3}) +def test_autosectionlabel_maxdepth(app, status, warning): + app.build(force_all=True) + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + + # depth: 1 + html = ('
  • ' + 'test-ext-autosectionlabel

  • ') + assert re.search(html, content, re.DOTALL) + + # depth: 2 + html = ('
  • ' + 'Installation

  • ') + assert re.search(html, content, re.DOTALL) + + # depth: 3 + html = ('
  • ' + 'For Windows users

  • ') + assert re.search(html, content, re.DOTALL) + + # depth: 4 + html = '
  • Linux

  • ' + assert re.search(html, content, re.DOTALL) + + assert "WARNING: undefined label: 'linux'" in warning.getvalue() -- cgit v1.2.3