summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-intl/xx/LC_MESSAGES/figure.po22
-rw-r--r--tests/test_build_epub.py4
-rw-r--r--tests/test_build_html.py32
-rw-r--r--tests/test_build_latex.py11
-rw-r--r--tests/test_build_manpage.py12
-rw-r--r--tests/test_domain_cpp.py5
-rw-r--r--tests/test_domain_py.py87
-rw-r--r--tests/test_domain_std.py3
-rw-r--r--tests/test_environment.py2
-rw-r--r--tests/test_ext_autodoc.py37
-rw-r--r--tests/test_ext_autodoc_autofunction.py29
-rw-r--r--tests/test_ext_autosectionlabel.py8
-rw-r--r--tests/test_ext_math.py4
-rw-r--r--tests/test_ext_todo.py4
-rw-r--r--tests/test_intl.py12
-rw-r--r--tests/test_pycode_parser.py7
-rw-r--r--tests/test_search.py10
-rw-r--r--tests/test_smartquotes.py8
-rw-r--r--tests/test_theming.py2
-rw-r--r--tests/test_util_inspect.py5
-rw-r--r--tests/test_util_pycompat.py38
21 files changed, 130 insertions, 212 deletions
diff --git a/tests/roots/test-intl/xx/LC_MESSAGES/figure.po b/tests/roots/test-intl/xx/LC_MESSAGES/figure.po
index 449b15e3f..64bbdf763 100644
--- a/tests/roots/test-intl/xx/LC_MESSAGES/figure.po
+++ b/tests/roots/test-intl/xx/LC_MESSAGES/figure.po
@@ -37,19 +37,17 @@ msgstr "BLOCK"
msgid "image url and alt"
msgstr "IMAGE URL AND ALT"
-msgid ""
-".. image:: img.png\n"
-" :alt: img"
-msgstr ""
-".. image:: i18n.png\n"
-" :alt: IMG -> I18N"
+msgid "img"
+msgstr "IMG -> I18N"
-msgid ""
-".. image:: i18n.png\n"
-" :alt: i18n"
-msgstr ""
-".. image:: img.png\n"
-" :alt: I18N -> IMG"
+msgid ".. image:: img.png"
+msgstr ".. image:: i18n.png"
+
+msgid "i18n"
+msgstr "I18N -> IMG"
+
+msgid ".. image:: i18n.png"
+msgstr ".. image:: img.png"
msgid "image on substitution"
msgstr "IMAGE ON SUBSTITUTION"
diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py
index 982f4c1b9..c468b093d 100644
--- a/tests/test_build_epub.py
+++ b/tests/test_build_epub.py
@@ -15,8 +15,6 @@ from xml.etree import ElementTree
import pytest
-from sphinx.util import docutils
-
# check given command is runnable
def runnable(command):
@@ -355,8 +353,6 @@ def test_epub_css_files(app):
'href="https://example.com/custom.css" />' not in content)
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('epub', testroot='roles-download')
def test_html_download_role(app, status, warning):
app.build()
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index d7b572abd..6bfbe422b 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -21,7 +21,7 @@ from html5lib import HTMLParser
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
from sphinx.errors import ConfigError
from sphinx.testing.util import strip_escseq
-from sphinx.util import docutils, md5
+from sphinx.util import md5
from sphinx.util.inventory import InventoryFile
ENV_WARNINGS = """\
@@ -410,8 +410,6 @@ def test_html4_output(app, status, warning):
(".//a[@href='_sources/otherext.foo.txt']", ''),
]
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', tags=['testtag'],
confoverrides={'html_context.hckey_co': 'hcval_co'})
@pytest.mark.test_params(shared_result='test_build_html_output')
@@ -426,8 +424,6 @@ def test_html_parallel(app):
app.build()
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html')
@pytest.mark.test_params(shared_result='test_build_html_output')
def test_html_download(app):
@@ -452,8 +448,6 @@ def test_html_download(app):
assert matched.group(1) == filename
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='roles-download')
def test_html_download_role(app, status, warning):
app.build()
@@ -532,8 +526,6 @@ def test_html_translator(app):
(".//h1//span[@class='section-number']", '2.1.1. ', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='tocdepth')
@pytest.mark.test_params(shared_result='test_build_html_tocdepth')
def test_tocdepth(app, cached_etree_parse, fname, expect):
@@ -579,8 +571,6 @@ def test_tocdepth(app, cached_etree_parse, fname, expect):
(".//h4//span[@class='section-number']", '2.1.1. ', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('singlehtml', testroot='tocdepth')
@pytest.mark.test_params(shared_result='test_build_html_tocdepth')
def test_tocdepth_singlehtml(app, cached_etree_parse, fname, expect):
@@ -638,8 +628,6 @@ def test_numfig_disabled_warn(app, warning):
"span[@class='caption-number']", None, True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='numfig')
@pytest.mark.test_params(shared_result='test_build_html_numfig')
def test_numfig_disabled(app, cached_etree_parse, fname, expect):
@@ -746,8 +734,6 @@ def test_numfig_without_numbered_toctree_warn(app, warning):
"span[@class='caption-number']", '^Listing 6 $', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx(
'html', testroot='numfig',
srcdir='test_numfig_without_numbered_toctree',
@@ -854,8 +840,6 @@ def test_numfig_with_numbered_toctree_warn(app, warning):
"span[@class='caption-number']", '^Listing 2.2 $', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='numfig', confoverrides={'numfig': True})
@pytest.mark.test_params(shared_result='test_build_html_numfig_on')
def test_numfig_with_numbered_toctree(app, cached_etree_parse, fname, expect):
@@ -959,8 +943,6 @@ def test_numfig_with_prefix_warn(app, warning):
"span[@class='caption-number']", '^Code-2.2 $', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='numfig',
confoverrides={'numfig': True,
'numfig_format': {'figure': 'Figure:%s',
@@ -1065,8 +1047,6 @@ def test_numfig_with_secnum_depth_warn(app, warning):
"span[@class='caption-number']", '^Listing 2.1.2 $', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='numfig',
confoverrides={'numfig': True,
'numfig_secnum_depth': 2})
@@ -1150,8 +1130,6 @@ def test_numfig_with_secnum_depth(app, cached_etree_parse, fname, expect):
"span[@class='caption-number']", '^Listing 2.2 $', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('singlehtml', testroot='numfig', confoverrides={'numfig': True})
@pytest.mark.test_params(shared_result='test_build_html_numfig_on')
def test_numfig_with_singlehtml(app, cached_etree_parse, fname, expect):
@@ -1176,8 +1154,6 @@ def test_numfig_with_singlehtml(app, cached_etree_parse, fname, expect):
(".//li/p/a/span", 'No.2', True),
],
}))
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='add_enumerable_node',
srcdir='test_enumerable_node')
def test_enumerable_node(app, cached_etree_parse, fname, expect):
@@ -1244,7 +1220,7 @@ def test_assets_order(app):
content = (app.outdir / 'index.html').read_text()
# css_files
- expected = ['_static/pygments.css', '_static/alabaster.css', '_static/early.css',
+ expected = ['_static/early.css', '_static/pygments.css', '_static/alabaster.css',
'https://example.com/custom.css', '_static/normal.css', '_static/late.css',
'_static/css/style.css', '_static/lazy.css']
pattern = '.*'.join('href="%s"' % f for f in expected)
@@ -1382,8 +1358,8 @@ def test_alternate_stylesheets(app, cached_etree_parse, fname, expect):
def test_html_style(app, status, warning):
app.build()
result = (app.outdir / 'index.html').read_text()
- assert '<link rel="stylesheet" href="_static/default.css" type="text/css" />' in result
- assert ('<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />'
+ assert '<link rel="stylesheet" type="text/css" href="_static/default.css" />' in result
+ assert ('<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />'
not in result)
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index 6f6041aea..58b9bc419 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -21,7 +21,6 @@ from sphinx.builders.latex import default_latex_documents
from sphinx.config import Config
from sphinx.errors import SphinxError
from sphinx.testing.util import strip_escseq
-from sphinx.util import docutils
from sphinx.util.osutil import cd, ensuredir
from sphinx.writers.latex import LaTeXTranslator
@@ -198,7 +197,7 @@ def test_latex_basic_manual_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
- assert r'\def\sphinxdocclass{jsbook}' in result
+ assert r'\def\sphinxdocclass{ujbook}' in result
assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result
@@ -211,7 +210,7 @@ def test_latex_basic_howto_ja(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').read_text(encoding='utf8')
print(result)
- assert r'\def\sphinxdocclass{jreport}' in result
+ assert r'\def\sphinxdocclass{ujreport}' in result
assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxhowto}' in result
@@ -1124,8 +1123,6 @@ def test_maxlistdepth_at_ten(app, status, warning):
compile_latex_document(app, 'python.tex')
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('latex', testroot='latex-table')
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_tabulars(app, status, warning):
@@ -1195,8 +1192,6 @@ def test_latex_table_tabulars(app, status, warning):
assert actual == expected
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('latex', testroot='latex-table')
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_longtable(app, status, warning):
@@ -1256,8 +1251,6 @@ def test_latex_table_longtable(app, status, warning):
assert actual == expected
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('latex', testroot='latex-table')
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_complex_tables(app, status, warning):
diff --git a/tests/test_build_manpage.py b/tests/test_build_manpage.py
index a017abc69..2affb8ba3 100644
--- a/tests/test_build_manpage.py
+++ b/tests/test_build_manpage.py
@@ -17,9 +17,9 @@ from sphinx.config import Config
@pytest.mark.sphinx('man')
def test_all(app, status, warning):
app.builder.build_all()
- assert (app.outdir / 'sphinxtests.1').exists()
+ assert (app.outdir / '1' / 'sphinxtests.1').exists()
- content = (app.outdir / 'sphinxtests.1').read_text()
+ content = (app.outdir / '1' / 'sphinxtests.1').read_text()
assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content
assert r'\fBmanpage\en\fP' in content
@@ -31,16 +31,16 @@ def test_all(app, status, warning):
@pytest.mark.sphinx('man', testroot='basic',
- confoverrides={'man_make_section_directory': True})
+ confoverrides={'man_make_section_directory': False})
def test_man_make_section_directory(app, status, warning):
app.build()
- assert (app.outdir / '1' / 'python.1').exists()
+ assert (app.outdir / 'python.1').exists()
@pytest.mark.sphinx('man', testroot='directive-code')
def test_captioned_code_block(app, status, warning):
app.builder.build_all()
- content = (app.outdir / 'python.1').read_text()
+ content = (app.outdir / '1' / 'python.1').read_text()
assert ('.sp\n'
'caption \\fItest\\fP rb\n'
@@ -71,5 +71,5 @@ def test_default_man_pages():
@pytest.mark.sphinx('man', testroot='markup-rubric')
def test_rubric(app, status, warning):
app.build()
- content = (app.outdir / 'python.1').read_text()
+ content = (app.outdir / '1' / 'python.1').read_text()
assert 'This is a rubric\n' in content
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 690093f5c..da05c1261 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -21,7 +21,6 @@ from sphinx.domains.cpp import (DefinitionError, DefinitionParser, NoOldIdError,
from sphinx.ext.intersphinx import load_mappings, normalize_intersphinx_mapping
from sphinx.testing import restructuredtext
from sphinx.testing.util import assert_node
-from sphinx.util import docutils
def parse(name, string):
@@ -1081,8 +1080,6 @@ def test_build_domain_cpp_misuse_of_roles(app, status, warning):
assert len(ws) == len(warn)
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': True})
def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, warning):
app.builder.build_all()
@@ -1124,8 +1121,6 @@ def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, war
check(s, t, f)
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': False})
def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, warning):
app.builder.build_all()
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index fe117659a..a1e37fa5e 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -214,20 +214,22 @@ def test_domain_py_find_obj(app, status, warning):
assert (find_obj(None, None, 'NONEXISTANT', 'class') == [])
assert (find_obj(None, None, 'NestedParentA', 'class') ==
- [('NestedParentA', ('roles', 'NestedParentA', 'class'))])
+ [('NestedParentA', ('roles', 'NestedParentA', 'class', False))])
assert (find_obj(None, None, 'NestedParentA.NestedChildA', 'class') ==
- [('NestedParentA.NestedChildA', ('roles', 'NestedParentA.NestedChildA', 'class'))])
+ [('NestedParentA.NestedChildA',
+ ('roles', 'NestedParentA.NestedChildA', 'class', False))])
assert (find_obj(None, 'NestedParentA', 'NestedChildA', 'class') ==
- [('NestedParentA.NestedChildA', ('roles', 'NestedParentA.NestedChildA', 'class'))])
+ [('NestedParentA.NestedChildA',
+ ('roles', 'NestedParentA.NestedChildA', 'class', False))])
assert (find_obj(None, None, 'NestedParentA.NestedChildA.subchild_1', 'meth') ==
[('NestedParentA.NestedChildA.subchild_1',
- ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
+ ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method', False))])
assert (find_obj(None, 'NestedParentA', 'NestedChildA.subchild_1', 'meth') ==
[('NestedParentA.NestedChildA.subchild_1',
- ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
+ ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method', False))])
assert (find_obj(None, 'NestedParentA.NestedChildA', 'subchild_1', 'meth') ==
[('NestedParentA.NestedChildA.subchild_1',
- ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
+ ('roles', 'NestedParentA.NestedChildA.subchild_1', 'method', False))])
def test_get_full_qualified_name():
@@ -529,7 +531,7 @@ def test_pydata(app):
[desc_content, ()])]))
assert_node(doctree[3][0][2][1], pending_xref, **{"py:module": "example"})
assert 'example.var' in domain.objects
- assert domain.objects['example.var'] == ('index', 'example.var', 'data')
+ assert domain.objects['example.var'] == ('index', 'example.var', 'data', False)
def test_pyfunction(app):
@@ -559,9 +561,9 @@ def test_pyfunction(app):
entries=[('single', 'func2() (in module example)', 'example.func2', '', None)])
assert 'func1' in domain.objects
- assert domain.objects['func1'] == ('index', 'func1', 'function')
+ assert domain.objects['func1'] == ('index', 'func1', 'function', False)
assert 'example.func2' in domain.objects
- assert domain.objects['example.func2'] == ('index', 'example.func2', 'function')
+ assert domain.objects['example.func2'] == ('index', 'example.func2', 'function', False)
def test_pyclass_options(app):
@@ -583,13 +585,13 @@ def test_pyclass_options(app):
assert_node(doctree[0], addnodes.index,
entries=[('single', 'Class1 (built-in class)', 'Class1', '', None)])
assert 'Class1' in domain.objects
- assert domain.objects['Class1'] == ('index', 'Class1', 'class')
+ assert domain.objects['Class1'] == ('index', 'Class1', 'class', False)
# :final:
assert_node(doctree[2], addnodes.index,
entries=[('single', 'Class2 (built-in class)', 'Class2', '', None)])
assert 'Class2' in domain.objects
- assert domain.objects['Class2'] == ('index', 'Class2', 'class')
+ assert domain.objects['Class2'] == ('index', 'Class2', 'class', False)
def test_pymethod_options(app):
@@ -635,7 +637,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth1' in domain.objects
- assert domain.objects['Class.meth1'] == ('index', 'Class.meth1', 'method')
+ assert domain.objects['Class.meth1'] == ('index', 'Class.meth1', 'method', False)
# :classmethod:
assert_node(doctree[1][1][2], addnodes.index,
@@ -645,7 +647,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth2' in domain.objects
- assert domain.objects['Class.meth2'] == ('index', 'Class.meth2', 'method')
+ assert domain.objects['Class.meth2'] == ('index', 'Class.meth2', 'method', False)
# :staticmethod:
assert_node(doctree[1][1][4], addnodes.index,
@@ -655,7 +657,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth3' in domain.objects
- assert domain.objects['Class.meth3'] == ('index', 'Class.meth3', 'method')
+ assert domain.objects['Class.meth3'] == ('index', 'Class.meth3', 'method', False)
# :async:
assert_node(doctree[1][1][6], addnodes.index,
@@ -665,7 +667,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth4' in domain.objects
- assert domain.objects['Class.meth4'] == ('index', 'Class.meth4', 'method')
+ assert domain.objects['Class.meth4'] == ('index', 'Class.meth4', 'method', False)
# :property:
assert_node(doctree[1][1][8], addnodes.index,
@@ -674,7 +676,7 @@ def test_pymethod_options(app):
[desc_name, "meth5"])],
[desc_content, ()]))
assert 'Class.meth5' in domain.objects
- assert domain.objects['Class.meth5'] == ('index', 'Class.meth5', 'method')
+ assert domain.objects['Class.meth5'] == ('index', 'Class.meth5', 'method', False)
# :abstractmethod:
assert_node(doctree[1][1][10], addnodes.index,
@@ -684,7 +686,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth6' in domain.objects
- assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method')
+ assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method', False)
# :final:
assert_node(doctree[1][1][12], addnodes.index,
@@ -694,7 +696,7 @@ def test_pymethod_options(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth7' in domain.objects
- assert domain.objects['Class.meth7'] == ('index', 'Class.meth7', 'method')
+ assert domain.objects['Class.meth7'] == ('index', 'Class.meth7', 'method', False)
def test_pyclassmethod(app):
@@ -715,7 +717,7 @@ def test_pyclassmethod(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth' in domain.objects
- assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method')
+ assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method', False)
def test_pystaticmethod(app):
@@ -736,7 +738,7 @@ def test_pystaticmethod(app):
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth' in domain.objects
- assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method')
+ assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method', False)
def test_pyattribute(app):
@@ -765,7 +767,7 @@ def test_pyattribute(app):
assert_node(doctree[1][1][1][0][1][1], pending_xref, **{"py:class": "Class"})
assert_node(doctree[1][1][1][0][1][3], pending_xref, **{"py:class": "Class"})
assert 'Class.attr' in domain.objects
- assert domain.objects['Class.attr'] == ('index', 'Class.attr', 'attribute')
+ assert domain.objects['Class.attr'] == ('index', 'Class.attr', 'attribute', False)
def test_pydecorator_signature(app):
@@ -780,7 +782,7 @@ def test_pydecorator_signature(app):
domain="py", objtype="function", noindex=False)
assert 'deco' in domain.objects
- assert domain.objects['deco'] == ('index', 'deco', 'function')
+ assert domain.objects['deco'] == ('index', 'deco', 'function', False)
def test_pydecoratormethod_signature(app):
@@ -795,7 +797,22 @@ def test_pydecoratormethod_signature(app):
domain="py", objtype="method", noindex=False)
assert 'deco' in domain.objects
- assert domain.objects['deco'] == ('index', 'deco', 'method')
+ assert domain.objects['deco'] == ('index', 'deco', 'method', False)
+
+
+def test_canonical(app):
+ text = (".. py:class:: io.StringIO\n"
+ " :canonical: _io.StringIO")
+ domain = app.env.get_domain('py')
+ doctree = restructuredtext.parse(app, text)
+ assert_node(doctree, (addnodes.index,
+ [desc, ([desc_signature, ([desc_annotation, "class "],
+ [desc_addname, "io."],
+ [desc_name, "StringIO"])],
+ desc_content)]))
+ assert 'io.StringIO' in domain.objects
+ assert domain.objects['io.StringIO'] == ('index', 'io.StringIO', 'class', False)
+ assert domain.objects['_io.StringIO'] == ('index', 'io.StringIO', 'class', True)
def test_info_field_list(app):
@@ -845,6 +862,30 @@ def test_info_field_list(app):
**{"py:module": "example", "py:class": "Class"})
+def test_info_field_list_var(app):
+ text = (".. py:class:: Class\n"
+ "\n"
+ " :var int attr: blah blah\n")
+ doctree = restructuredtext.parse(app, text)
+
+ assert_node(doctree, (addnodes.index,
+ [desc, (desc_signature,
+ [desc_content, nodes.field_list, nodes.field])]))
+ assert_node(doctree[1][1][0][0], ([nodes.field_name, "Variables"],
+ [nodes.field_body, nodes.paragraph]))
+
+ # :var int attr:
+ assert_node(doctree[1][1][0][0][1][0],
+ ([addnodes.literal_strong, "attr"],
+ " (",
+ [pending_xref, addnodes.literal_emphasis, "int"],
+ ")",
+ " -- ",
+ "blah blah"))
+ assert_node(doctree[1][1][0][0][1][0][2], pending_xref,
+ refdomain="py", reftype="class", reftarget="int", **{"py:class": "Class"})
+
+
@pytest.mark.sphinx(freshenv=True)
def test_module_index(app):
text = (".. py:module:: docutils\n"
diff --git a/tests/test_domain_std.py b/tests/test_domain_std.py
index 628b538b7..d0230ee2e 100644
--- a/tests/test_domain_std.py
+++ b/tests/test_domain_std.py
@@ -21,7 +21,6 @@ from sphinx.addnodes import (desc, desc_addname, desc_content, desc_name, desc_s
from sphinx.domains.std import StandardDomain
from sphinx.testing import restructuredtext
from sphinx.testing.util import assert_node
-from sphinx.util import docutils
def test_process_doc_handle_figure_caption():
@@ -349,8 +348,6 @@ def test_multiple_cmdoptions(app):
assert domain.progoptions[('cmd', '--output')] == ('index', 'cmdoption-cmd-o')
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx(testroot='productionlist')
def test_productionlist(app, status, warning):
app.builder.build_all()
diff --git a/tests/test_environment.py b/tests/test_environment.py
index ccf396d9c..650d12bfb 100644
--- a/tests/test_environment.py
+++ b/tests/test_environment.py
@@ -85,7 +85,7 @@ def test_object_inventory(app):
refs = app.env.domaindata['py']['objects']
assert 'func_without_module' in refs
- assert refs['func_without_module'] == ('objects', 'func_without_module', 'function')
+ assert refs['func_without_module'] == ('objects', 'func_without_module', 'function', False)
assert 'func_without_module2' in refs
assert 'mod.func_in_module' in refs
assert 'mod.Cls' in refs
diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py
index 4ac9381ae..e00ab0ee2 100644
--- a/tests/test_ext_autodoc.py
+++ b/tests/test_ext_autodoc.py
@@ -286,7 +286,6 @@ def test_format_signature(app):
'(b, c=42, *d, **e)'
-@pytest.mark.skipif(sys.version_info < (3, 5), reason='typing is available since python3.5.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_process_signature_typing_generic(app):
actual = do_autodoc(app, 'class', 'target.generic_class.A', {})
@@ -1557,7 +1556,6 @@ def test_partialmethod_undoc_members(app):
assert list(actual) == expected
-@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_typed_instance_variables(app):
options = {"members": None,
@@ -1656,7 +1654,6 @@ def test_autodoc_typed_instance_variables(app):
]
-@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_typed_inherited_instance_variables(app):
options = {"members": None,
@@ -1862,7 +1859,6 @@ def test_autodoc_Annotated(app):
]
-@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_TYPE_CHECKING(app):
options = {"members": None,
@@ -1911,26 +1907,19 @@ def test_autodoc_for_egged_code(app):
def test_singledispatch(app):
options = {"members": None}
actual = do_autodoc(app, 'module', 'target.singledispatch', options)
- if sys.version_info < (3, 6):
- # check the result via "in" because the order of singledispatch signatures is
- # usually changed (because dict is not OrderedDict yet!)
- assert '.. py:function:: func(arg, kwarg=None)' in actual
- assert ' func(arg: int, kwarg=None)' in actual
- assert ' func(arg: str, kwarg=None)' in actual
- else:
- assert list(actual) == [
- '',
- '.. py:module:: target.singledispatch',
- '',
- '',
- '.. py:function:: func(arg, kwarg=None)',
- ' func(arg: int, kwarg=None)',
- ' func(arg: str, kwarg=None)',
- ' :module: target.singledispatch',
- '',
- ' A function for general use.',
- '',
- ]
+ assert list(actual) == [
+ '',
+ '.. py:module:: target.singledispatch',
+ '',
+ '',
+ '.. py:function:: func(arg, kwarg=None)',
+ ' func(arg: int, kwarg=None)',
+ ' func(arg: str, kwarg=None)',
+ ' :module: target.singledispatch',
+ '',
+ ' A function for general use.',
+ '',
+ ]
@pytest.mark.skipif(sys.version_info < (3, 8),
diff --git a/tests/test_ext_autodoc_autofunction.py b/tests/test_ext_autodoc_autofunction.py
index aa0476687..615091889 100644
--- a/tests/test_ext_autodoc_autofunction.py
+++ b/tests/test_ext_autodoc_autofunction.py
@@ -9,8 +9,6 @@
:license: BSD, see LICENSE for details.
"""
-import sys
-
import pytest
from .test_ext_autodoc import do_autodoc
@@ -118,23 +116,16 @@ def test_decorated(app):
def test_singledispatch(app):
options = {}
actual = do_autodoc(app, 'function', 'target.singledispatch.func', options)
- if sys.version_info < (3, 6):
- # check the result via "in" because the order of singledispatch signatures is
- # usually changed (because dict is not OrderedDict yet!)
- assert '.. py:function:: func(arg, kwarg=None)' in actual
- assert ' func(arg: int, kwarg=None)' in actual
- assert ' func(arg: str, kwarg=None)' in actual
- else:
- assert list(actual) == [
- '',
- '.. py:function:: func(arg, kwarg=None)',
- ' func(arg: int, kwarg=None)',
- ' func(arg: str, kwarg=None)',
- ' :module: target.singledispatch',
- '',
- ' A function for general use.',
- '',
- ]
+ assert list(actual) == [
+ '',
+ '.. py:function:: func(arg, kwarg=None)',
+ ' func(arg: int, kwarg=None)',
+ ' func(arg: str, kwarg=None)',
+ ' :module: target.singledispatch',
+ '',
+ ' A function for general use.',
+ '',
+ ]
@pytest.mark.sphinx('html', testroot='ext-autodoc')
diff --git a/tests/test_ext_autosectionlabel.py b/tests/test_ext_autosectionlabel.py
index 0afe13b41..96f81aacd 100644
--- a/tests/test_ext_autosectionlabel.py
+++ b/tests/test_ext_autosectionlabel.py
@@ -12,11 +12,7 @@ import re
import pytest
-from sphinx.util import docutils
-
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
app.builder.build_all()
@@ -55,15 +51,11 @@ def test_autosectionlabel_html(app, status, warning, skipped_labels=False):
# Re-use test definition from above, just change the test root directory
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
def test_autosectionlabel_prefix_document_html(app, status, warning):
test_autosectionlabel_html(app, status, warning)
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel',
confoverrides={'autosectionlabel_maxdepth': 3})
def test_autosectionlabel_maxdepth(app, status, warning):
diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py
index 10c8c4866..bd124c8c6 100644
--- a/tests/test_ext_math.py
+++ b/tests/test_ext_math.py
@@ -72,8 +72,8 @@ def test_mathjax_options(app, status, warning):
content = (app.outdir / 'index.html').read_text()
assert ('<script async="async" integrity="sha384-0123456789" '
- 'src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?'
- 'config=TeX-AMS-MML_HTMLorMML"></script>' in content)
+ 'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">'
+ '</script>' in content)
@pytest.mark.sphinx('html', testroot='ext-math',
diff --git a/tests/test_ext_todo.py b/tests/test_ext_todo.py
index b6fb2549c..b4f969004 100644
--- a/tests/test_ext_todo.py
+++ b/tests/test_ext_todo.py
@@ -12,11 +12,7 @@ import re
import pytest
-from sphinx.util import docutils
-
-@pytest.mark.skipif(docutils.__version_info__ < (0, 13),
- reason='docutils-0.13 or above is required')
@pytest.mark.sphinx('html', testroot='ext-todo', freshenv=True,
confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True})
def test_todo(app, status, warning):
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 00f599595..fa6a41079 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -335,9 +335,9 @@ def test_text_figure_captions(app):
"14.2. IMAGE URL AND ALT\n"
"=======================\n"
"\n"
- "[image: i18n][image]\n"
+ "[image: I18N -> IMG][image]\n"
"\n"
- " [image: img][image]\n"
+ " [image: IMG -> I18N][image]\n"
"\n"
"\n"
"14.3. IMAGE ON SUBSTITUTION\n"
@@ -1090,12 +1090,12 @@ def test_additional_targets_should_not_be_translated(app):
result = (app.outdir / 'figure.html').read_text()
- # alt and src for image block should not be translated
- expected_expr = """<img alt="i18n" src="_images/i18n.png" />"""
+ # src for image block should not be translated (alt is translated)
+ expected_expr = """<img alt="I18N -&gt; IMG" src="_images/i18n.png" />"""
assert_count(expected_expr, result, 1)
- # alt and src for figure block should not be translated
- expected_expr = """<img alt="img" src="_images/img.png" />"""
+ # src for figure block should not be translated (alt is translated)
+ expected_expr = """<img alt="IMG -&gt; I18N" src="_images/img.png" />"""
assert_count(expected_expr, result, 1)
diff --git a/tests/test_pycode_parser.py b/tests/test_pycode_parser.py
index 9169315fc..e9099178d 100644
--- a/tests/test_pycode_parser.py
+++ b/tests/test_pycode_parser.py
@@ -8,10 +8,6 @@
:license: BSD, see LICENSE for details.
"""
-import sys
-
-import pytest
-
from sphinx.pycode.parser import Parser
from sphinx.util.inspect import signature_from_str
@@ -95,8 +91,7 @@ def test_comment_picker_location():
('Foo', 'attr3'): 'comment for attr3(3)'}
-@pytest.mark.skipif(sys.version_info < (3, 6), reason='tests for py36+ syntax')
-def test_annotated_assignment_py36():
+def test_annotated_assignment():
source = ('a: str = "Sphinx" #: comment\n'
'b: int = 1\n'
'"""string on next line"""\n'
diff --git a/tests/test_search.py b/tests/test_search.py
index 1ceb6d55b..dc4f546ca 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -143,6 +143,7 @@ def test_IndexBuilder():
assert index._titles == {'docname': 'title', 'docname2': 'title2'}
assert index._filenames == {'docname': 'filename', 'docname2': 'filename2'}
assert index._mapping == {
+ 'ar': {'docname', 'docname2'},
'fermion': {'docname', 'docname2'},
'comment': {'docname', 'docname2'},
'non': {'docname', 'docname2'},
@@ -161,7 +162,8 @@ def test_IndexBuilder():
'objects': {'': {'objdispname': (0, 0, 1, '#anchor')}},
'objnames': {0: ('dummy', 'objtype', 'objtype')},
'objtypes': {0: 'dummy:objtype'},
- 'terms': {'comment': [0, 1],
+ 'terms': {'ar': [0, 1],
+ 'comment': [0, 1],
'fermion': [0, 1],
'index': [0, 1],
'non': [0, 1],
@@ -197,6 +199,7 @@ def test_IndexBuilder():
assert index._titles == {'docname2': 'title2'}
assert index._filenames == {'docname2': 'filename2'}
assert index._mapping == {
+ 'ar': {'docname2'},
'fermion': {'docname2'},
'comment': {'docname2'},
'non': {'docname2'},
@@ -215,7 +218,8 @@ def test_IndexBuilder():
'objects': {},
'objnames': {0: ('dummy', 'objtype', 'objtype')},
'objtypes': {0: 'dummy:objtype'},
- 'terms': {'comment': 0,
+ 'terms': {'ar': 0,
+ 'comment': 0,
'fermion': 0,
'index': 0,
'non': 0,
@@ -261,4 +265,4 @@ def test_nosearch(app):
assert index['docnames'] == ['index', 'nosearch', 'tocitem']
assert 'latex' not in index['terms']
assert 'zfs' in index['terms']
- assert index['terms']['zfs'] == 0 # zfs on nosearch.rst is not registered to index
+ assert index['terms']['zfs'] == [] # zfs on nosearch.rst is not registered to index
diff --git a/tests/test_smartquotes.py b/tests/test_smartquotes.py
index 0cc0681dc..a8d4b1ed6 100644
--- a/tests/test_smartquotes.py
+++ b/tests/test_smartquotes.py
@@ -10,8 +10,6 @@
import pytest
-from sphinx.util import docutils
-
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True)
def test_basic(app, status, warning):
@@ -33,7 +31,7 @@ def test_text_builder(app, status, warning):
def test_man_builder(app, status, warning):
app.build()
- content = (app.outdir / 'python.1').read_text()
+ content = (app.outdir / '1' / 'python.1').read_text()
assert '\\-\\- "Sphinx" is a tool that makes it easy ...' in content
@@ -63,8 +61,6 @@ def test_smartquotes_disabled(app, status, warning):
assert '<p>-- &quot;Sphinx&quot; is a tool that makes it easy ...</p>' in content
-@pytest.mark.skipif(docutils.__version_info__ < (0, 14),
- reason='docutils-0.14 or above is required')
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True,
confoverrides={'smartquotes_action': 'q'})
def test_smartquotes_action(app, status, warning):
@@ -88,5 +84,5 @@ def test_smartquotes_excludes_language(app, status, warning):
def test_smartquotes_excludes_builders(app, status, warning):
app.build()
- content = (app.outdir / 'python.1').read_text()
+ content = (app.outdir / '1' / 'python.1').read_text()
assert '– “Sphinx” is a tool that makes it easy …' in content
diff --git a/tests/test_theming.py b/tests/test_theming.py
index 9d447537c..3b5d59ec6 100644
--- a/tests/test_theming.py
+++ b/tests/test_theming.py
@@ -127,7 +127,7 @@ def test_dark_style(app, status, warning):
assert (app.outdir / '_static' / 'pygments_dark.css').exists()
result = (app.outdir / 'index.html').read_text()
- assert '<link rel="stylesheet" href="_static/pygments.css" type="text/css" />' in result
+ assert '<link rel="stylesheet" type="text/css" href="_static/pygments.css" />' in result
assert ('<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" '
'rel="stylesheet" type="text/css" '
'href="_static/pygments_dark.css" />') in result
diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py
index 863f44921..bf2021063 100644
--- a/tests/test_util_inspect.py
+++ b/tests/test_util_inspect.py
@@ -223,10 +223,7 @@ def test_signature_annotations():
# type hints by string
sig = inspect.signature(Node.children)
- if (3, 5, 0) <= sys.version_info < (3, 5, 3):
- assert stringify_signature(sig) == '(self) -> List[Node]'
- else:
- assert stringify_signature(sig) == '(self) -> List[tests.typing_test_data.Node]'
+ assert stringify_signature(sig) == '(self) -> List[tests.typing_test_data.Node]'
sig = inspect.signature(Node.__init__)
assert stringify_signature(sig) == '(self, parent: Optional[tests.typing_test_data.Node]) -> None'
diff --git a/tests/test_util_pycompat.py b/tests/test_util_pycompat.py
deleted file mode 100644
index 0e395fa7a..000000000
--- a/tests/test_util_pycompat.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
- test_util_pycompat
- ~~~~~~~~~~~~~~~~~~
-
- Tests sphinx.util.pycompat functions.
-
- :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-from sphinx.testing.util import strip_escseq
-from sphinx.util import logging
-from sphinx.util.pycompat import execfile_
-
-
-def test_execfile_python2(capsys, app, status, warning, tempdir):
- logging.setup(app, status, warning)
-
- conf_py = tempdir / 'conf.py'
- conf_py.write_bytes(b'print "hello"\n')
- execfile_(conf_py, {})
-
- msg = (
- 'Support for evaluating Python 2 syntax is deprecated '
- 'and will be removed in Sphinx 4.0. '
- 'Convert %s to Python 3 syntax.\n' % conf_py)
- assert msg in strip_escseq(warning.getvalue())
- captured = capsys.readouterr()
- assert captured.out == 'hello\n'
-
-
-def test_execfile(capsys, tempdir):
- conf_py = tempdir / 'conf.py'
- conf_py.write_bytes(b'print("hello")\n')
- execfile_(conf_py, {})
-
- captured = capsys.readouterr()
- assert captured.out == 'hello\n'