From ac399b3b4e52f96cae53e1b257df408920092fa4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 11 Feb 2019 18:34:04 +0900 Subject: [PATCH] refactor tests for autosectionlabel --- .../index.rst | 8 +++ .../roots/test-ext-autosectionlabel/index.rst | 1 + tests/test_ext_autosectionlabel.py | 54 +++++++++++-------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst b/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst index 10fa2662d..d767373c2 100644 --- a/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst +++ b/tests/roots/test-ext-autosectionlabel-prefix-document/index.rst @@ -15,6 +15,12 @@ For Windows users For UNIX users -------------- +Linux +^^^^^ + +FreeBSD +^^^^^^^ + This one's got an apostrophe ---------------------------- @@ -26,4 +32,6 @@ References * :ref:`index:Installation` * :ref:`index:For Windows users` * :ref:`index:For UNIX users` +* :ref:`index:Linux` +* :ref:`index:FreeBSD` * :ref:`index:This one's got an apostrophe` diff --git a/tests/roots/test-ext-autosectionlabel/index.rst b/tests/roots/test-ext-autosectionlabel/index.rst index 7d1b39ded..133206ed6 100644 --- a/tests/roots/test-ext-autosectionlabel/index.rst +++ b/tests/roots/test-ext-autosectionlabel/index.rst @@ -27,6 +27,7 @@ This one's got an apostrophe References ========== +* :ref:`test-ext-autosectionlabel` * :ref:`Introduce of Sphinx` * :ref:`Installation` * :ref:`For Windows users` diff --git a/tests/test_ext_autosectionlabel.py b/tests/test_ext_autosectionlabel.py index 7960e2943..5e83cacf6 100644 --- a/tests/test_ext_autosectionlabel.py +++ b/tests/test_ext_autosectionlabel.py @@ -34,26 +34,13 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False): 'For UNIX users') assert re.search(html, content, re.S) - if skipped_labels is None: - return + html = ('
  • ' + 'Linux
  • ') + assert re.search(html, content, re.S) - if not skipped_labels: - html = ('
  • ' - 'Linux
  • ') - assert re.search(html, content, re.S) - - html = ('
  • ' - 'FreeBSD
  • ') - assert re.search(html, content, re.S) - else: - html = '
  • Linux
  • ' - assert re.search(html, content, re.S) - - html = '
  • FreeBSD
  • ' - assert re.search(html, content, re.S) - - assert 'WARNING: undefined label: linux' in warning.getvalue() - assert 'WARNING: undefined label: freebsd' in warning.getvalue() + html = ('
  • ' + 'FreeBSD
  • ') + assert re.search(html, content, re.S) # for smart_quotes (refs: #4027) html = ('
  • ' + 'test-ext-autosectionlabel
  • ') + assert re.search(html, content, re.S) + + # depth: 2 + html = ('
  • ' + 'Installation
  • ') + assert re.search(html, content, re.S) + + # depth: 3 + html = ('
  • ' + 'For Windows users
  • ') + assert re.search(html, content, re.S) + + # depth: 4 + html = '
  • Linux
  • ' + assert re.search(html, content, re.S) + + assert 'WARNING: undefined label: linux' in warning.getvalue()