mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Move autodoc_missing_imports to test-ext-autodoc
This commit is contained in:
@@ -45,5 +45,3 @@ Just testing a few autodoc possibilities...
|
|||||||
:members: ca1, ia1
|
:members: ca1, ia1
|
||||||
|
|
||||||
Specific members (2 total)
|
Specific members (2 total)
|
||||||
|
|
||||||
.. automodule:: autodoc_missing_imports
|
|
||||||
|
|||||||
@@ -69,14 +69,6 @@ coverage_c_regexes = {'function': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'}
|
|||||||
extlinks = {'issue': ('http://bugs.python.org/issue%s', 'issue '),
|
extlinks = {'issue': ('http://bugs.python.org/issue%s', 'issue '),
|
||||||
'pyurl': ('http://python.org/%s', None)}
|
'pyurl': ('http://python.org/%s', None)}
|
||||||
|
|
||||||
autodoc_mock_imports = [
|
|
||||||
'missing_module',
|
|
||||||
'missing_package1',
|
|
||||||
'missing_package2',
|
|
||||||
'missing_package3',
|
|
||||||
'sphinx.missing_module4',
|
|
||||||
]
|
|
||||||
|
|
||||||
# modify tags from conf.py
|
# modify tags from conf.py
|
||||||
tags.add('confpytag') # NOQA
|
tags.add('confpytag') # NOQA
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ IS_PYPY = platform.python_implementation() == 'PyPy'
|
|||||||
def do_autodoc(app, objtype, name, options=None):
|
def do_autodoc(app, objtype, name, options=None):
|
||||||
if options is None:
|
if options is None:
|
||||||
options = {}
|
options = {}
|
||||||
|
app.env.temp_data.setdefault('docname', 'index') # set dummy docname
|
||||||
doccls = app.registry.documenters[objtype]
|
doccls = app.registry.documenters[objtype]
|
||||||
docoptions = process_documenter_options(doccls, app.config, options)
|
docoptions = process_documenter_options(doccls, app.config, options)
|
||||||
bridge = DocumenterBridge(app.env, LoggingReporter(''), docoptions, 1)
|
bridge = DocumenterBridge(app.env, LoggingReporter(''), docoptions, 1)
|
||||||
@@ -1348,33 +1349,49 @@ def test_autofunction_for_callable(app):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='root')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_mocked_module_imports(app):
|
def test_mocked_module_imports(app, warning):
|
||||||
|
# no autodoc_mock_imports
|
||||||
options = {"members": 'TestAutodoc,decoratedFunction'}
|
options = {"members": 'TestAutodoc,decoratedFunction'}
|
||||||
actual = do_autodoc(app, 'module', 'autodoc_missing_imports', options)
|
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||||
|
assert list(actual) == []
|
||||||
|
assert "autodoc: failed to import module 'need_mocks'" in warning.getvalue()
|
||||||
|
|
||||||
|
# with autodoc_mock_imports
|
||||||
|
app.config.autodoc_mock_imports = [
|
||||||
|
'missing_module',
|
||||||
|
'missing_package1',
|
||||||
|
'missing_package2',
|
||||||
|
'missing_package3',
|
||||||
|
'sphinx.missing_module4',
|
||||||
|
]
|
||||||
|
|
||||||
|
warning.truncate(0)
|
||||||
|
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
'.. py:module:: autodoc_missing_imports',
|
'.. py:module:: target.need_mocks',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'.. py:class:: TestAutodoc',
|
'.. py:class:: TestAutodoc',
|
||||||
' :module: autodoc_missing_imports',
|
' :module: target.need_mocks',
|
||||||
'',
|
'',
|
||||||
' TestAutodoc docstring.',
|
' TestAutodoc docstring.',
|
||||||
' ',
|
' ',
|
||||||
' ',
|
' ',
|
||||||
' .. py:method:: TestAutodoc.decoratedMethod()',
|
' .. py:method:: TestAutodoc.decoratedMethod()',
|
||||||
' :module: autodoc_missing_imports',
|
' :module: target.need_mocks',
|
||||||
' ',
|
' ',
|
||||||
' TestAutodoc::decoratedMethod docstring',
|
' TestAutodoc::decoratedMethod docstring',
|
||||||
' ',
|
' ',
|
||||||
'',
|
'',
|
||||||
'.. py:function:: decoratedFunction()',
|
'.. py:function:: decoratedFunction()',
|
||||||
' :module: autodoc_missing_imports',
|
' :module: target.need_mocks',
|
||||||
'',
|
'',
|
||||||
' decoratedFunction docstring',
|
' decoratedFunction docstring',
|
||||||
' '
|
' '
|
||||||
]
|
]
|
||||||
|
assert warning.getvalue() == ''
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('setup_test')
|
@pytest.mark.usefixtures('setup_test')
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ def test_texinfo(app, status, warning):
|
|||||||
TexinfoTranslator.ignore_missing_images = True
|
TexinfoTranslator.ignore_missing_images = True
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
result = (app.outdir / 'SphinxTests.texi').text(encoding='utf8')
|
result = (app.outdir / 'SphinxTests.texi').text(encoding='utf8')
|
||||||
assert ('@anchor{markup doc}@anchor{12}'
|
assert ('@anchor{markup doc}@anchor{11}'
|
||||||
'@anchor{markup id1}@anchor{13}'
|
'@anchor{markup id1}@anchor{12}'
|
||||||
'@anchor{markup testing-various-markup}@anchor{14}' in result)
|
'@anchor{markup testing-various-markup}@anchor{13}' in result)
|
||||||
# now, try to run makeinfo over it
|
# now, try to run makeinfo over it
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
os.chdir(app.outdir)
|
os.chdir(app.outdir)
|
||||||
|
|||||||
Reference in New Issue
Block a user