diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-09-21 00:49:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 00:49:23 +0900 |
| commit | b454d4e4b0801105ad1517289c972ca2030cedd7 (patch) | |
| tree | cb715a3a29d8c7cf0ebf11f2b70abb4b5a4eeb80 /tests | |
| parent | fd3d654c17874d4cbffbd8e9379728f83a31b30b (diff) | |
| parent | 3c017dcdee6b9f4b7f5e46b3b0ba2cebced4d4dc (diff) | |
| download | sphinx-git-b454d4e4b0801105ad1517289c972ca2030cedd7.tar.gz | |
Merge branch '3.x' into 8190_autodoc-process-docstring-without_ending_blankline
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/roots/test-ext-autodoc/target/cached_property.py | 7 | ||||
| -rw-r--r-- | tests/test_build_html.py | 8 | ||||
| -rw-r--r-- | tests/test_ext_autodoc.py | 20 |
3 files changed, 34 insertions, 1 deletions
diff --git a/tests/roots/test-ext-autodoc/target/cached_property.py b/tests/roots/test-ext-autodoc/target/cached_property.py new file mode 100644 index 000000000..63ec09f8e --- /dev/null +++ b/tests/roots/test-ext-autodoc/target/cached_property.py @@ -0,0 +1,7 @@ +from functools import cached_property + + +class Foo: + @cached_property + def prop(self) -> int: + return 1 diff --git a/tests/test_build_html.py b/tests/test_build_html.py index e949f1157..1efc6c14a 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -10,8 +10,10 @@ import os import re +from distutils.version import LooseVersion from itertools import cycle, chain +import pygments import pytest from html5lib import HTMLParser @@ -1591,4 +1593,8 @@ def test_html_codeblock_linenos_style_inline(app): app.build() content = (app.outdir / 'index.html').read_text() - assert '<span class="lineno">1 </span>' in content + pygments_version = tuple(LooseVersion(pygments.__version__).version) + if pygments_version > (2, 7): + assert '<span class="linenos">1</span>' in content + else: + assert '<span class="lineno">1 </span>' in content diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py index 90a2ec95a..1ba64a0a7 100644 --- a/tests/test_ext_autodoc.py +++ b/tests/test_ext_autodoc.py @@ -881,6 +881,26 @@ def test_autodoc_descriptor(app): ] +@pytest.mark.skipif(sys.version_info < (3, 8), + reason='cached_property is available since python3.8.') +@pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_autodoc_cached_property(app): + options = {"members": None, + "undoc-members": True} + actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options) + assert list(actual) == [ + '', + '.. py:class:: Foo()', + ' :module: target.cached_property', + '', + '', + ' .. py:method:: Foo.prop', + ' :module: target.cached_property', + ' :property:', + '', + ] + + @pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_member_order(app): # case member-order='bysource' |
