mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Move InventoryFile class to sphinx.util.inventory
This commit is contained in:
@@ -9,70 +9,18 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import posixpath
|
||||
import unittest
|
||||
import zlib
|
||||
|
||||
from six import BytesIO
|
||||
from docutils import nodes
|
||||
import mock
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.ext.intersphinx import setup as intersphinx_setup
|
||||
from sphinx.ext.intersphinx import InventoryFile, \
|
||||
load_mappings, missing_reference, _strip_basic_auth, \
|
||||
from sphinx.ext.intersphinx import (
|
||||
load_mappings, missing_reference, _strip_basic_auth,
|
||||
_get_safe_url, fetch_inventory, INVENTORY_FILENAME
|
||||
|
||||
|
||||
inventory_v1 = '''\
|
||||
# Sphinx inventory version 1
|
||||
# Project: foo
|
||||
# Version: 1.0
|
||||
module mod foo.html
|
||||
module.cls class foo.html
|
||||
'''.encode('utf-8')
|
||||
|
||||
inventory_v2 = '''\
|
||||
# Sphinx inventory version 2
|
||||
# Project: foo
|
||||
# Version: 2.0
|
||||
# The remainder of this file is compressed with zlib.
|
||||
'''.encode('utf-8') + zlib.compress('''\
|
||||
module1 py:module 0 foo.html#module-module1 Long Module desc
|
||||
module2 py:module 0 foo.html#module-$ -
|
||||
module1.func py:function 1 sub/foo.html#$ -
|
||||
CFunc c:function 2 cfunc.html#CFunc -
|
||||
a term std:term -1 glossary.html#term-a-term -
|
||||
docname std:doc -1 docname.html -
|
||||
a term including:colon std:term -1 glossary.html#term-a-term-including-colon -
|
||||
'''.encode('utf-8'))
|
||||
|
||||
|
||||
def test_read_inventory_v1():
|
||||
f = BytesIO(inventory_v1)
|
||||
invdata = InventoryFile.load(f, '/util', posixpath.join)
|
||||
assert invdata['py:module']['module'] == \
|
||||
('foo', '1.0', '/util/foo.html#module-module', '-')
|
||||
assert invdata['py:class']['module.cls'] == \
|
||||
('foo', '1.0', '/util/foo.html#module.cls', '-')
|
||||
|
||||
|
||||
def test_read_inventory_v2():
|
||||
f = BytesIO(inventory_v2)
|
||||
invdata = InventoryFile.load(f, '/util', posixpath.join)
|
||||
|
||||
assert len(invdata['py:module']) == 2
|
||||
assert invdata['py:module']['module1'] == \
|
||||
('foo', '2.0', '/util/foo.html#module-module1', 'Long Module desc')
|
||||
assert invdata['py:module']['module2'] == \
|
||||
('foo', '2.0', '/util/foo.html#module-module2', '-')
|
||||
assert invdata['py:function']['module1.func'][2] == \
|
||||
'/util/sub/foo.html#module1.func'
|
||||
assert invdata['c:function']['CFunc'][2] == '/util/cfunc.html#CFunc'
|
||||
assert invdata['std:term']['a term'][2] == \
|
||||
'/util/glossary.html#term-a-term'
|
||||
assert invdata['std:term']['a term including:colon'][2] == \
|
||||
'/util/glossary.html#term-a-term-including-colon'
|
||||
)
|
||||
from test_util_inventory import inventory_v2
|
||||
|
||||
|
||||
@mock.patch('sphinx.ext.intersphinx.InventoryFile')
|
||||
|
||||
Reference in New Issue
Block a user