diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-01-08 01:37:53 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-01-08 01:37:53 +0900 |
commit | af2a3c0ddeb2f81c8f685e4d266adefc749a2642 (patch) | |
tree | f4b5f634fcc3e2315bf5eedaceed11a16ba0ff14 /tests/test_util_nodes.py | |
parent | 92a204284b98510b3bfdd2a6391e9855c564a6a0 (diff) | |
parent | 8e1cbd24c61934df7eb426aad0dc48830789b096 (diff) | |
download | sphinx-git-af2a3c0ddeb2f81c8f685e4d266adefc749a2642.tar.gz |
Merge branch '2.0'
Diffstat (limited to 'tests/test_util_nodes.py')
-rw-r--r-- | tests/test_util_nodes.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_util_nodes.py b/tests/test_util_nodes.py index b1a6b7d1d..76ba51800 100644 --- a/tests/test_util_nodes.py +++ b/tests/test_util_nodes.py @@ -17,7 +17,9 @@ from docutils.parsers import rst from docutils.utils import new_document from sphinx.transforms import ApplySourceWorkaround -from sphinx.util.nodes import NodeMatcher, extract_messages, clean_astext, split_explicit_title +from sphinx.util.nodes import ( + NodeMatcher, extract_messages, clean_astext, make_id, split_explicit_title +) def _transform(doctree): @@ -27,6 +29,7 @@ def _transform(doctree): def create_new_document(): settings = frontend.OptionParser( components=(rst.Parser,)).get_default_values() + settings.id_prefix = 'id' document = new_document('dummy.txt', settings) return document @@ -180,6 +183,20 @@ def test_clean_astext(): assert 'hello world' == clean_astext(node) +def test_make_id(app): + document = create_new_document() + assert make_id(app.env, document) == 'id0' + assert make_id(app.env, document, 'term') == 'term-0' + assert make_id(app.env, document, 'term', 'Sphinx') == 'term-sphinx' + + # when same ID is already registered + document.ids['term-sphinx'] = True + assert make_id(app.env, document, 'term', 'Sphinx') == 'term-1' + + document.ids['term-2'] = True + assert make_id(app.env, document, 'term') == 'term-3' + + @pytest.mark.parametrize( 'title, expected', [ |