From 3f617a4a9b6c1a628a0be3f6d0a5cf4f27cfac7e Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 3 Jun 2019 01:07:17 +0900 Subject: [PATCH] test: Update testcase for between() --- .../target/process_docstring.py | 8 +++ tests/test_autodoc.py | 52 +++++++++++-------- 2 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 tests/roots/test-ext-autodoc/target/process_docstring.py diff --git a/tests/roots/test-ext-autodoc/target/process_docstring.py b/tests/roots/test-ext-autodoc/target/process_docstring.py new file mode 100644 index 000000000..6005943b6 --- /dev/null +++ b/tests/roots/test-ext-autodoc/target/process_docstring.py @@ -0,0 +1,8 @@ +def func(): + """ + first line + --- + second line + --- + third line + """ diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 967eb30b3..99eb2eb86 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -506,32 +506,38 @@ def test_docstring_processing(): assert process('function', 'f', f) == ['second line', ''] app.disconnect(lid) - lid = app.connect('autodoc-process-docstring', between('---', ['function'])) - def g(): - """ - first line - --- - second line - --- - third line - """ - assert process('function', 'g', g) == ['second line', ''] - app.disconnect(lid) +@pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_between(app): + app.connect('autodoc-process-docstring', + between('---', ['function'])) - lid = 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', + '', + ' second line', + ' ' + ] - def h(): - """ - first line - --- - second line - --- - third line - """ - assert process('function', 'h', h) == ['first line', 'third line', ''] - app.disconnect(lid) + +@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')