diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-01-23 20:09:47 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-01-23 20:09:47 +0900 |
commit | d8a398bbdda113c5ee2d1447acbe3feaf2d40bf6 (patch) | |
tree | d04b4e12966c6767c40ec3570e0a0d8dcdd8a803 /tests/test_ext_extlinks.py | |
parent | 2be06309518d9401a42880bb5b4321dfdd1e5e90 (diff) | |
download | sphinx-git-d8a398bbdda113c5ee2d1447acbe3feaf2d40bf6.tar.gz |
Close #10125: extlinks: Improve suggestion message for a reference having title
Diffstat (limited to 'tests/test_ext_extlinks.py')
-rw-r--r-- | tests/test_ext_extlinks.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/test_ext_extlinks.py b/tests/test_ext_extlinks.py index 2be9789f0..9b0e96cb0 100644 --- a/tests/test_ext_extlinks.py +++ b/tests/test_ext_extlinks.py @@ -5,14 +5,15 @@ import pytest def test_replaceable_uris_emit_extlinks_warnings(app, warning): app.build() warning_output = warning.getvalue() + # there should be exactly three warnings for replaceable URLs message = ( - "WARNING: hardcoded link 'https://github.com/sphinx-doc/sphinx/issues/1' " - "could be replaced by an extlink (try using ':issue:`1`' instead)" + "index.rst:%d: WARNING: hardcoded link 'https://github.com/sphinx-doc/sphinx/issues/1' " + "could be replaced by an extlink (try using '%s' instead)" ) - assert f"index.rst:11: {message}" in warning_output - assert f"index.rst:13: {message}" in warning_output - assert f"index.rst:15: {message}" in warning_output + assert message % (11, ":issue:`1`") in warning_output + assert message % (13, ":issue:`inline replaceable link <1>`") in warning_output + assert message % (15, ":issue:`replaceable link <1>`") in warning_output @pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls-multiple-replacements') @@ -21,16 +22,16 @@ def test_all_replacements_suggested_if_multiple_replacements_possible(app, warni warning_output = warning.getvalue() # there should be six warnings for replaceable URLs, three pairs per link message = ( - "WARNING: hardcoded link 'https://github.com/octocat' " - "could be replaced by an extlink (try using ':user:`octocat`' instead)" + "index.rst:%d: WARNING: hardcoded link 'https://github.com/octocat' " + "could be replaced by an extlink (try using '%s' instead)" ) - assert f"index.rst:14: {message}" in warning_output - assert f"index.rst:16: {message}" in warning_output - assert f"index.rst:18: {message}" in warning_output + assert message % (14, ":user:`octocat`") in warning_output + assert message % (16, ":user:`inline replaceable link <octocat>`") in warning_output + assert message % (18, ":user:`replaceable link <octocat>`") in warning_output message = ( - "WARNING: hardcoded link 'https://github.com/octocat' " - "could be replaced by an extlink (try using ':repo:`octocat`' instead)" + "index.rst:%d: WARNING: hardcoded link 'https://github.com/octocat' " + "could be replaced by an extlink (try using '%s' instead)" ) - assert f"index.rst:14: {message}" in warning_output - assert f"index.rst:16: {message}" in warning_output - assert f"index.rst:18: {message}" in warning_output + assert message % (14, ":repo:`octocat`") in warning_output + assert message % (16, ":repo:`inline replaceable link <octocat>`") in warning_output + assert message % (18, ":repo:`replaceable link <octocat>`") in warning_output |