summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-03 01:32:01 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-03 01:32:36 +0900
commitc8554e7673a97dd2eb4984877cbcfffdcc739e5c (patch)
tree8aac111a232cad9d14735b6be89eae3b68952d9f
parent7de8c63407b11ad59ba1df9baf2fffd174bee02e (diff)
downloadsphinx-git-c8554e7673a97dd2eb4984877cbcfffdcc739e5c.tar.gz
test: Move testcases for autodoc events to test_ext_autodoc_events
-rw-r--r--tests/test_autodoc.py69
-rw-r--r--tests/test_ext_autodoc_events.py81
2 files changed, 82 insertions, 68 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index 3cd39538a..877c8a204 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -16,7 +16,7 @@ from warnings import catch_warnings
import pytest
from docutils.statemachine import ViewList
-from sphinx.ext.autodoc import ModuleLevelDocumenter, cut_lines, between, ALL, Options
+from sphinx.ext.autodoc import ModuleLevelDocumenter, ALL, Options
from sphinx.ext.autodoc.directive import DocumenterBridge, process_documenter_options
from sphinx.testing.util import SphinxTestApp, Struct # NOQA
from sphinx.util import logging
@@ -465,73 +465,6 @@ def test_get_doc():
@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_process_docstring(app):
- def on_process_docstring(app, what, name, obj, options, lines):
- lines.clear()
- lines.append('my docstring')
-
- app.connect('autodoc-process-docstring', on_process_docstring)
-
- actual = do_autodoc(app, 'function', 'target.process_docstring.func')
- assert list(actual) == [
- '',
- '.. py:function:: func()',
- ' :module: target.process_docstring',
- '',
- ' my docstring'
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_cut_lines(app):
- app.connect('autodoc-process-docstring',
- cut_lines(2, 2, ['function']))
-
- actual = do_autodoc(app, 'function', 'target.process_docstring.func')
- assert list(actual) == [
- '',
- '.. py:function:: func()',
- ' :module: target.process_docstring',
- '',
- ' second line',
- ' '
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_between(app):
- app.connect('autodoc-process-docstring',
- between('---', ['function']))
-
- actual = do_autodoc(app, 'function', 'target.process_docstring.func')
- assert list(actual) == [
- '',
- '.. py:function:: func()',
- ' :module: target.process_docstring',
- '',
- ' second line',
- ' '
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_between_exclude(app):
- app.connect('autodoc-process-docstring',
- between('---', ['function'], exclude=True))
-
- actual = do_autodoc(app, 'function', 'target.process_docstring.func')
- assert list(actual) == [
- '',
- '.. py:function:: func()',
- ' :module: target.process_docstring',
- '',
- ' first line',
- ' third line',
- ' '
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_new_documenter(app):
class MyDocumenter(ModuleLevelDocumenter):
objtype = 'integer'
diff --git a/tests/test_ext_autodoc_events.py b/tests/test_ext_autodoc_events.py
new file mode 100644
index 000000000..647def3d7
--- /dev/null
+++ b/tests/test_ext_autodoc_events.py
@@ -0,0 +1,81 @@
+"""
+ test_ext_autodoc_events
+ ~~~~~~~~~~~~~~~~~~~~~~~
+
+ Test the autodoc extension. This tests mainly for autodoc events
+
+ :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import pytest
+
+from sphinx.ext.autodoc import between, cut_lines
+from test_autodoc import do_autodoc
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_process_docstring(app):
+ def on_process_docstring(app, what, name, obj, options, lines):
+ lines.clear()
+ lines.append('my docstring')
+
+ app.connect('autodoc-process-docstring', on_process_docstring)
+
+ actual = do_autodoc(app, 'function', 'target.process_docstring.func')
+ assert list(actual) == [
+ '',
+ '.. py:function:: func()',
+ ' :module: target.process_docstring',
+ '',
+ ' my docstring'
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_cut_lines(app):
+ app.connect('autodoc-process-docstring',
+ cut_lines(2, 2, ['function']))
+
+ actual = do_autodoc(app, 'function', 'target.process_docstring.func')
+ assert list(actual) == [
+ '',
+ '.. py:function:: func()',
+ ' :module: target.process_docstring',
+ '',
+ ' second line',
+ ' '
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_between(app):
+ app.connect('autodoc-process-docstring',
+ between('---', ['function']))
+
+ actual = do_autodoc(app, 'function', 'target.process_docstring.func')
+ assert list(actual) == [
+ '',
+ '.. py:function:: func()',
+ ' :module: target.process_docstring',
+ '',
+ ' second line',
+ ' '
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_between_exclude(app):
+ app.connect('autodoc-process-docstring',
+ between('---', ['function'], exclude=True))
+
+ actual = do_autodoc(app, 'function', 'target.process_docstring.func')
+ assert list(actual) == [
+ '',
+ '.. py:function:: func()',
+ ' :module: target.process_docstring',
+ '',
+ ' first line',
+ ' third line',
+ ' '
+ ]