Merge pull request #4665 from tk0miya/4664_broken_intersphinx_cmdline

Fix #4664: Reading objects.inv fails again
This commit is contained in:
Takeshi KOMIYA
2018-02-23 22:56:58 +09:00
committed by GitHub
3 changed files with 25 additions and 11 deletions

View File

@@ -14,6 +14,8 @@ Deprecated
``sphinx.cmd.build.build_main()`` instead.
* autosummary: The interface of ``sphinx.ext.autosummary.get_documenter()`` has
been changed (Since 1.7.0)
* #4664: ``sphinx.ext.intersphinx.debug()`` is deprecated. Use
``sphinx.ext.intersphinx.inspect_main()`` instead.
Features added
--------------
@@ -39,6 +41,7 @@ Bugs fixed
* C++, add missing parsing of ``this`` in expression parsing.
* #4655: Fix incomplete localization strings in Polish
* #4653: Fix error reporting for parameterless ImportErrors
* #4664: Reading objects.inv fails again
Testing
--------

View File

@@ -30,6 +30,7 @@ import functools
import posixpath
import sys
import time
import warnings
from os import path
from typing import TYPE_CHECKING
@@ -40,6 +41,7 @@ from six.moves.urllib.parse import urlsplit, urlunsplit
import sphinx
from sphinx.builders.html import INVENTORY_FILENAME
from sphinx.deprecation import RemovedInSphinx20Warning
from sphinx.locale import _
from sphinx.util import requests, logging
from sphinx.util.inventory import InventoryFile
@@ -373,6 +375,15 @@ def setup(app):
def debug(argv):
# type: (List[unicode]) -> None
"""Debug functionality to print out an inventory"""
warnings.warn('sphinx.ext.intersphinx.debug() is deprecated. '
'Please use inspect_main() instead',
RemovedInSphinx20Warning)
inspect_main(argv[1:])
def inspect_main(argv):
# type: (List[unicode]) -> None
"""Debug functionality to print out an inventory"""
if len(argv) < 1:
@@ -406,4 +417,4 @@ if __name__ == '__main__':
import logging # type: ignore
logging.basicConfig()
debug(argv=sys.argv[1:]) # type: ignore
inspect_main(argv=sys.argv[1:]) # type: ignore

View File

@@ -22,7 +22,7 @@ from test_util_inventory import inventory_v2, inventory_v2_not_having_version
from sphinx import addnodes
from sphinx.ext.intersphinx import (
load_mappings, missing_reference, _strip_basic_auth,
_get_safe_url, fetch_inventory, INVENTORY_FILENAME, debug
_get_safe_url, fetch_inventory, INVENTORY_FILENAME, inspect_main
)
from sphinx.ext.intersphinx import setup as intersphinx_setup
@@ -393,10 +393,10 @@ def test_getsafeurl_unauthed():
assert expected == actual
def test_debug_noargs(capsys):
"""debug interface, without arguments"""
def test_inspect_main_noargs(capsys):
"""inspect_main interface, without arguments"""
with pytest.raises(SystemExit):
debug(['sphinx/ext/intersphinx.py'])
inspect_main([])
expected = (
"Print out an inventory file.\n"
@@ -407,12 +407,12 @@ def test_debug_noargs(capsys):
assert stderr == expected + "\n"
def test_debug_file(capsys, tempdir):
"""debug interface, with file argument"""
def test_inspect_main_file(capsys, tempdir):
"""inspect_main interface, with file argument"""
inv_file = tempdir / 'inventory'
inv_file.write_bytes(inventory_v2)
debug(['sphinx/ext/intersphinx.py', str(inv_file)])
inspect_main([str(inv_file)])
stdout, stderr = capsys.readouterr()
assert stdout.startswith("c:function\n")
@@ -420,8 +420,8 @@ def test_debug_file(capsys, tempdir):
@mock.patch('requests.get')
def test_debug_url(fake_get, capsys):
"""debug interface, with url argument"""
def test_inspect_main_url(fake_get, capsys):
"""inspect_main interface, with url argument"""
raw = BytesIO(inventory_v2)
real_read = raw.read
@@ -436,7 +436,7 @@ def test_debug_url(fake_get, capsys):
resp.raw = raw
fake_get.return_value = resp
debug(['sphinx/ext/intersphinx.py', url])
inspect_main([url])
stdout, stderr = capsys.readouterr()
assert stdout.startswith("c:function\n")