mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5546 from tk0miya/refactor_test_root
test: Move autodoc_missing_imports to test-ext-autodoc
This commit is contained in:
commit
a4cce3e561
@ -45,5 +45,3 @@ Just testing a few autodoc possibilities...
|
||||
:members: ca1, ia1
|
||||
|
||||
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 '),
|
||||
'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
|
||||
tags.add('confpytag') # NOQA
|
||||
|
||||
|
@ -35,6 +35,7 @@ IS_PYPY = platform.python_implementation() == 'PyPy'
|
||||
def do_autodoc(app, objtype, name, options=None):
|
||||
if options is None:
|
||||
options = {}
|
||||
app.env.temp_data.setdefault('docname', 'index') # set dummy docname
|
||||
doccls = app.registry.documenters[objtype]
|
||||
docoptions = process_documenter_options(doccls, app.config, options)
|
||||
bridge = DocumenterBridge(app.env, LoggingReporter(''), docoptions, 1)
|
||||
@ -1348,33 +1349,49 @@ def test_autofunction_for_callable(app):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_mocked_module_imports(app):
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_mocked_module_imports(app, warning):
|
||||
# no autodoc_mock_imports
|
||||
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) == [
|
||||
'',
|
||||
'.. py:module:: autodoc_missing_imports',
|
||||
'.. py:module:: target.need_mocks',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: TestAutodoc',
|
||||
' :module: autodoc_missing_imports',
|
||||
' :module: target.need_mocks',
|
||||
'',
|
||||
' TestAutodoc docstring.',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: TestAutodoc.decoratedMethod()',
|
||||
' :module: autodoc_missing_imports',
|
||||
' :module: target.need_mocks',
|
||||
' ',
|
||||
' TestAutodoc::decoratedMethod docstring',
|
||||
' ',
|
||||
'',
|
||||
'.. py:function:: decoratedFunction()',
|
||||
' :module: autodoc_missing_imports',
|
||||
' :module: target.need_mocks',
|
||||
'',
|
||||
' decoratedFunction docstring',
|
||||
' '
|
||||
]
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('setup_test')
|
||||
|
@ -47,9 +47,9 @@ def test_texinfo(app, status, warning):
|
||||
TexinfoTranslator.ignore_missing_images = True
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'SphinxTests.texi').text(encoding='utf8')
|
||||
assert ('@anchor{markup doc}@anchor{12}'
|
||||
'@anchor{markup id1}@anchor{13}'
|
||||
'@anchor{markup testing-various-markup}@anchor{14}' in result)
|
||||
assert ('@anchor{markup doc}@anchor{11}'
|
||||
'@anchor{markup id1}@anchor{12}'
|
||||
'@anchor{markup testing-various-markup}@anchor{13}' in result)
|
||||
# now, try to run makeinfo over it
|
||||
cwd = os.getcwd()
|
||||
os.chdir(app.outdir)
|
||||
|
Loading…
Reference in New Issue
Block a user