mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8461 from francoisfreitag/flake8-linkcheck
Make tests/ a Python package
This commit is contained in:
commit
a44027059c
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -6,7 +6,7 @@ source_suffix = '.txt'
|
|||||||
exclude_patterns = ['_build']
|
exclude_patterns = ['_build']
|
||||||
|
|
||||||
doctest_global_setup = '''
|
doctest_global_setup = '''
|
||||||
from test_ext_doctest import record
|
from tests.test_ext_doctest import record
|
||||||
|
|
||||||
record('doctest_global_setup', 'body', True)
|
record('doctest_global_setup', 'body', True)
|
||||||
'''
|
'''
|
||||||
|
@ -139,7 +139,7 @@ Special directives
|
|||||||
|
|
||||||
.. testcleanup:: *
|
.. testcleanup:: *
|
||||||
|
|
||||||
import test_ext_doctest
|
from tests import test_ext_doctest
|
||||||
test_ext_doctest.cleanup_call()
|
test_ext_doctest.cleanup_call()
|
||||||
|
|
||||||
non-ASCII result
|
non-ASCII result
|
||||||
|
@ -16,7 +16,6 @@ from shutil import copyfile
|
|||||||
from subprocess import PIPE, CalledProcessError
|
from subprocess import PIPE, CalledProcessError
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_build_html import ENV_WARNINGS
|
|
||||||
|
|
||||||
from sphinx.builders.latex import default_latex_documents
|
from sphinx.builders.latex import default_latex_documents
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
@ -26,6 +25,8 @@ from sphinx.util import docutils
|
|||||||
from sphinx.util.osutil import cd, ensuredir
|
from sphinx.util.osutil import cd, ensuredir
|
||||||
from sphinx.writers.latex import LaTeXTranslator
|
from sphinx.writers.latex import LaTeXTranslator
|
||||||
|
|
||||||
|
from .test_build_html import ENV_WARNINGS
|
||||||
|
|
||||||
LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
|
LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
|
||||||
DOCCLASSES = ['howto', 'manual']
|
DOCCLASSES = ['howto', 'manual']
|
||||||
STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
|
STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
|
||||||
|
@ -15,7 +15,7 @@ import textwrap
|
|||||||
import pytest
|
import pytest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from utils import CERT_FILE, http_server, https_server, modify_env
|
from .utils import CERT_FILE, http_server, https_server, modify_env
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck', freshenv=True)
|
@pytest.mark.sphinx('linkcheck', testroot='linkcheck', freshenv=True)
|
||||||
|
@ -15,7 +15,6 @@ from subprocess import PIPE, CalledProcessError
|
|||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_build_html import ENV_WARNINGS
|
|
||||||
|
|
||||||
from sphinx.builders.texinfo import default_texinfo_documents
|
from sphinx.builders.texinfo import default_texinfo_documents
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
@ -23,6 +22,8 @@ from sphinx.testing.util import strip_escseq
|
|||||||
from sphinx.util.docutils import new_document
|
from sphinx.util.docutils import new_document
|
||||||
from sphinx.writers.texinfo import TexinfoTranslator
|
from sphinx.writers.texinfo import TexinfoTranslator
|
||||||
|
|
||||||
|
from .test_build_html import ENV_WARNINGS
|
||||||
|
|
||||||
TEXINFO_WARNINGS = ENV_WARNINGS + """\
|
TEXINFO_WARNINGS = ENV_WARNINGS + """\
|
||||||
%(root)s/index.rst:\\d+: WARNING: unknown option: &option
|
%(root)s/index.rst:\\d+: WARNING: unknown option: &option
|
||||||
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
|
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
@ -12,10 +12,11 @@ import platform
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
|
||||||
from sphinx.testing import restructuredtext
|
from sphinx.testing import restructuredtext
|
||||||
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
IS_PYPY = platform.python_implementation() == 'PyPy'
|
IS_PYPY = platform.python_implementation() == 'PyPy'
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
|
||||||
from sphinx.ext.autodoc import between, cut_lines
|
from sphinx.ext.autodoc import between, cut_lines
|
||||||
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_process_docstring(app):
|
def test_process_docstring(app):
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from test_ext_autodoc import do_autodoc
|
|
||||||
|
from .test_ext_autodoc import do_autodoc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
|
@ -15,14 +15,15 @@ from unittest import mock
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from test_util_inventory import inventory_v2, inventory_v2_not_having_version
|
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.ext.intersphinx import (INVENTORY_FILENAME, _get_safe_url, _strip_basic_auth,
|
from sphinx.ext.intersphinx import (INVENTORY_FILENAME, _get_safe_url, _strip_basic_auth,
|
||||||
fetch_inventory, inspect_main, load_mappings,
|
fetch_inventory, inspect_main, load_mappings,
|
||||||
missing_reference, normalize_intersphinx_mapping)
|
missing_reference, normalize_intersphinx_mapping)
|
||||||
from sphinx.ext.intersphinx import setup as intersphinx_setup
|
from sphinx.ext.intersphinx import setup as intersphinx_setup
|
||||||
from utils import http_server
|
|
||||||
|
from .test_util_inventory import inventory_v2, inventory_v2_not_having_version
|
||||||
|
from .utils import http_server
|
||||||
|
|
||||||
|
|
||||||
def fake_node(domain, type, target, content, **attrs):
|
def fake_node(domain, type, target, content, **attrs):
|
||||||
|
@ -129,8 +129,8 @@ def test_signature_partialmethod():
|
|||||||
|
|
||||||
|
|
||||||
def test_signature_annotations():
|
def test_signature_annotations():
|
||||||
from typing_test_data import (Node, f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
|
from .typing_test_data import (Node, f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
|
||||||
f13, f14, f15, f16, f17, f18, f19, f20, f21)
|
f13, f14, f15, f16, f17, f18, f19, f20, f21)
|
||||||
|
|
||||||
# Class annotations
|
# Class annotations
|
||||||
sig = inspect.signature(f0)
|
sig = inspect.signature(f0)
|
||||||
@ -226,10 +226,10 @@ def test_signature_annotations():
|
|||||||
if (3, 5, 0) <= sys.version_info < (3, 5, 3):
|
if (3, 5, 0) <= sys.version_info < (3, 5, 3):
|
||||||
assert stringify_signature(sig) == '(self) -> List[Node]'
|
assert stringify_signature(sig) == '(self) -> List[Node]'
|
||||||
else:
|
else:
|
||||||
assert stringify_signature(sig) == '(self) -> List[typing_test_data.Node]'
|
assert stringify_signature(sig) == '(self) -> List[tests.typing_test_data.Node]'
|
||||||
|
|
||||||
sig = inspect.signature(Node.__init__)
|
sig = inspect.signature(Node.__init__)
|
||||||
assert stringify_signature(sig) == '(self, parent: Optional[typing_test_data.Node]) -> None'
|
assert stringify_signature(sig) == '(self, parent: Optional[tests.typing_test_data.Node]) -> None'
|
||||||
|
|
||||||
# show_annotation is False
|
# show_annotation is False
|
||||||
sig = inspect.signature(f7)
|
sig = inspect.signature(f7)
|
||||||
|
@ -53,7 +53,7 @@ def test_restify_type_hints_containers():
|
|||||||
assert restify(Tuple[str, str, str]) == ":class:`Tuple`\\ [:class:`str`, :class:`str`, :class:`str`]"
|
assert restify(Tuple[str, str, str]) == ":class:`Tuple`\\ [:class:`str`, :class:`str`, :class:`str`]"
|
||||||
assert restify(Tuple[str, ...]) == ":class:`Tuple`\\ [:class:`str`, ...]"
|
assert restify(Tuple[str, ...]) == ":class:`Tuple`\\ [:class:`str`, ...]"
|
||||||
assert restify(List[Dict[str, Tuple]]) == ":class:`List`\\ [:class:`Dict`\\ [:class:`str`, :class:`Tuple`]]"
|
assert restify(List[Dict[str, Tuple]]) == ":class:`List`\\ [:class:`Dict`\\ [:class:`str`, :class:`Tuple`]]"
|
||||||
assert restify(MyList[Tuple[int, int]]) == ":class:`test_util_typing.MyList`\\ [:class:`Tuple`\\ [:class:`int`, :class:`int`]]"
|
assert restify(MyList[Tuple[int, int]]) == ":class:`tests.test_util_typing.MyList`\\ [:class:`Tuple`\\ [:class:`int`, :class:`int`]]"
|
||||||
assert restify(Generator[None, None, None]) == ":class:`Generator`\\ [:obj:`None`, :obj:`None`, :obj:`None`]"
|
assert restify(Generator[None, None, None]) == ":class:`Generator`\\ [:obj:`None`, :obj:`None`, :obj:`None`]"
|
||||||
|
|
||||||
|
|
||||||
@ -76,10 +76,10 @@ def test_restify_type_hints_Union():
|
|||||||
if sys.version_info >= (3, 7):
|
if sys.version_info >= (3, 7):
|
||||||
assert restify(Union[int, Integral]) == ":obj:`Union`\\ [:class:`int`, :class:`numbers.Integral`]"
|
assert restify(Union[int, Integral]) == ":obj:`Union`\\ [:class:`int`, :class:`numbers.Integral`]"
|
||||||
assert (restify(Union[MyClass1, MyClass2]) ==
|
assert (restify(Union[MyClass1, MyClass2]) ==
|
||||||
":obj:`Union`\\ [:class:`test_util_typing.MyClass1`, :class:`test_util_typing.<MyClass2>`]")
|
":obj:`Union`\\ [:class:`tests.test_util_typing.MyClass1`, :class:`tests.test_util_typing.<MyClass2>`]")
|
||||||
else:
|
else:
|
||||||
assert restify(Union[int, Integral]) == ":class:`numbers.Integral`"
|
assert restify(Union[int, Integral]) == ":class:`numbers.Integral`"
|
||||||
assert restify(Union[MyClass1, MyClass2]) == ":class:`test_util_typing.MyClass1`"
|
assert restify(Union[MyClass1, MyClass2]) == ":class:`tests.test_util_typing.MyClass1`"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required.')
|
@pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required.')
|
||||||
@ -88,15 +88,15 @@ def test_restify_type_hints_typevars():
|
|||||||
T_co = TypeVar('T_co', covariant=True)
|
T_co = TypeVar('T_co', covariant=True)
|
||||||
T_contra = TypeVar('T_contra', contravariant=True)
|
T_contra = TypeVar('T_contra', contravariant=True)
|
||||||
|
|
||||||
assert restify(T) == ":obj:`test_util_typing.T`"
|
assert restify(T) == ":obj:`tests.test_util_typing.T`"
|
||||||
assert restify(T_co) == ":obj:`test_util_typing.T_co`"
|
assert restify(T_co) == ":obj:`tests.test_util_typing.T_co`"
|
||||||
assert restify(T_contra) == ":obj:`test_util_typing.T_contra`"
|
assert restify(T_contra) == ":obj:`tests.test_util_typing.T_contra`"
|
||||||
assert restify(List[T]) == ":class:`List`\\ [:obj:`test_util_typing.T`]"
|
assert restify(List[T]) == ":class:`List`\\ [:obj:`tests.test_util_typing.T`]"
|
||||||
|
|
||||||
|
|
||||||
def test_restify_type_hints_custom_class():
|
def test_restify_type_hints_custom_class():
|
||||||
assert restify(MyClass1) == ":class:`test_util_typing.MyClass1`"
|
assert restify(MyClass1) == ":class:`tests.test_util_typing.MyClass1`"
|
||||||
assert restify(MyClass2) == ":class:`test_util_typing.<MyClass2>`"
|
assert restify(MyClass2) == ":class:`tests.test_util_typing.<MyClass2>`"
|
||||||
|
|
||||||
|
|
||||||
def test_restify_type_hints_alias():
|
def test_restify_type_hints_alias():
|
||||||
@ -107,7 +107,7 @@ def test_restify_type_hints_alias():
|
|||||||
|
|
||||||
|
|
||||||
def test_restify_broken_type_hints():
|
def test_restify_broken_type_hints():
|
||||||
assert restify(BrokenType) == ':class:`test_util_typing.BrokenType`'
|
assert restify(BrokenType) == ':class:`tests.test_util_typing.BrokenType`'
|
||||||
|
|
||||||
|
|
||||||
def test_stringify():
|
def test_stringify():
|
||||||
@ -127,7 +127,7 @@ def test_stringify_type_hints_containers():
|
|||||||
assert stringify(Tuple[str, str, str]) == "Tuple[str, str, str]"
|
assert stringify(Tuple[str, str, str]) == "Tuple[str, str, str]"
|
||||||
assert stringify(Tuple[str, ...]) == "Tuple[str, ...]"
|
assert stringify(Tuple[str, ...]) == "Tuple[str, ...]"
|
||||||
assert stringify(List[Dict[str, Tuple]]) == "List[Dict[str, Tuple]]"
|
assert stringify(List[Dict[str, Tuple]]) == "List[Dict[str, Tuple]]"
|
||||||
assert stringify(MyList[Tuple[int, int]]) == "test_util_typing.MyList[Tuple[int, int]]"
|
assert stringify(MyList[Tuple[int, int]]) == "tests.test_util_typing.MyList[Tuple[int, int]]"
|
||||||
assert stringify(Generator[None, None, None]) == "Generator[None, None, None]"
|
assert stringify(Generator[None, None, None]) == "Generator[None, None, None]"
|
||||||
|
|
||||||
|
|
||||||
@ -164,10 +164,10 @@ def test_stringify_type_hints_Union():
|
|||||||
if sys.version_info >= (3, 7):
|
if sys.version_info >= (3, 7):
|
||||||
assert stringify(Union[int, Integral]) == "Union[int, numbers.Integral]"
|
assert stringify(Union[int, Integral]) == "Union[int, numbers.Integral]"
|
||||||
assert (stringify(Union[MyClass1, MyClass2]) ==
|
assert (stringify(Union[MyClass1, MyClass2]) ==
|
||||||
"Union[test_util_typing.MyClass1, test_util_typing.<MyClass2>]")
|
"Union[tests.test_util_typing.MyClass1, tests.test_util_typing.<MyClass2>]")
|
||||||
else:
|
else:
|
||||||
assert stringify(Union[int, Integral]) == "numbers.Integral"
|
assert stringify(Union[int, Integral]) == "numbers.Integral"
|
||||||
assert stringify(Union[MyClass1, MyClass2]) == "test_util_typing.MyClass1"
|
assert stringify(Union[MyClass1, MyClass2]) == "tests.test_util_typing.MyClass1"
|
||||||
|
|
||||||
|
|
||||||
def test_stringify_type_hints_typevars():
|
def test_stringify_type_hints_typevars():
|
||||||
@ -182,8 +182,8 @@ def test_stringify_type_hints_typevars():
|
|||||||
|
|
||||||
|
|
||||||
def test_stringify_type_hints_custom_class():
|
def test_stringify_type_hints_custom_class():
|
||||||
assert stringify(MyClass1) == "test_util_typing.MyClass1"
|
assert stringify(MyClass1) == "tests.test_util_typing.MyClass1"
|
||||||
assert stringify(MyClass2) == "test_util_typing.<MyClass2>"
|
assert stringify(MyClass2) == "tests.test_util_typing.<MyClass2>"
|
||||||
|
|
||||||
|
|
||||||
def test_stringify_type_hints_alias():
|
def test_stringify_type_hints_alias():
|
||||||
@ -194,4 +194,4 @@ def test_stringify_type_hints_alias():
|
|||||||
|
|
||||||
|
|
||||||
def test_stringify_broken_type_hints():
|
def test_stringify_broken_type_hints():
|
||||||
assert stringify(BrokenType) == 'test_util_typing.BrokenType'
|
assert stringify(BrokenType) == 'tests.test_util_typing.BrokenType'
|
||||||
|
Loading…
Reference in New Issue
Block a user