repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
sphinx
tests/roots/test-ext-autosummary/autosummary_dummy_module.py
.py
from os import path from typing import Union from autosummary_class_module import Class __all__ = [ 'CONSTANT1', 'Exc', 'Foo', '_Baz', 'bar', 'qux', 'path', ] #: module variable CONSTANT1 = None CONSTANT2 = None class Foo: #: class variable CONSTANT3 = None CONSTANT4 = None ...
69
961
sphinx
tests/roots/test-ext-autosummary/autosummary_class_module.py
.py
class Class: pass
3
22
sphinx
tests/roots/test-latex-figure-in-admonition/conf.py
.py
extensions = ['sphinx.ext.todo'] todo_include_todos = True exclude_patterns = ['_build']
4
89
sphinx
tests/roots/test-ext-napoleon-paramtype/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.intersphinx', ] # Python inventory is manually created in the test # in order to avoid creating a real HTTP connection intersphinx_mapping = {} intersp...
17
376
sphinx
tests/roots/test-ext-napoleon-paramtype/pkg/bar.py
.py
class Bar: """The bar.""" def list(self) -> None: """A list method.""" @staticmethod def int() -> float: """An int method.""" return 1.0
11
179
sphinx
tests/roots/test-ext-napoleon-paramtype/pkg/foo.py
.py
class Foo: """The foo.""" def do( self, *, keyword_paramtype, keyword_kwtype, kwarg_paramtype, kwarg_kwtype, kwparam_paramtype, kwparam_kwtype, ): """Some method. :keyword keyword_paramtype: some param :paramtype keywo...
29
792
sphinx
tests/roots/test-epub-anchor-id/conf.py
.py
def setup(app): app.add_crossref_type(directivename='setting', rolename='setting')
3
87
sphinx
tests/roots/test-ext-autosummary-template/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['sphinx.ext.autosummary'] autosummary_generate = True autodoc_default_options = {'members': True} templates_path = ['_templates']
10
228
sphinx
tests/roots/test-ext-autosummary-template/target.py
.py
class Foo: """docstring of Foo."""
3
39
sphinx
tests/roots/test-ext-apidoc/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve() / 'src')) extensions = ['sphinx.ext.apidoc'] apidoc_include_private = True apidoc_follow_links = False apidoc_separate_modules = True apidoc_no_headings = False apidoc_module_first = True apidoc_modules = [ { 'path': 'src', ...
23
541
sphinx
tests/roots/test-ext-apidoc/src/my_package.py
.py
"""An example module.""" def example_function(a: str) -> str: """An example function.""" return a
7
108
sphinx
tests/roots/test-ext-extlinks-hardcoded-urls-multiple-replacements/conf.py
.py
extensions = ['sphinx.ext.extlinks'] extlinks = { 'user': ('https://github.com/%s', '@%s'), 'repo': ('https://github.com/%s', 'project %s'), } extlinks_detect_hardcoded_links = True
7
190
sphinx
tests/roots/test-ext-autosummary-imported_members/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['sphinx.ext.autosummary'] autosummary_generate = True autosummary_imported_members = True
9
188
sphinx
tests/roots/test-ext-autosummary-imported_members/autosummary_dummy_package/autosummary_dummy_module.py
.py
class Bar: """Bar class""" pass def foo(): """Foo function""" pass
10
86
sphinx
tests/roots/test-root/parsermod.py
.py
from docutils import nodes from docutils.parsers import Parser class Parser(Parser): supported = ('foo',) def parse(self, input, document): section = nodes.section(ids=['id1']) section += nodes.title('Generated section', 'Generated section') document += section def get_transforms...
15
346
sphinx
tests/roots/test-root/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) from docutils import nodes from docutils.parsers.rst import Directive from sphinx import addnodes extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.extlinks', ] jsmath_path = '...
170
4,456
sphinx
tests/roots/test-root/autodoc_target.py
.py
import enum from io import StringIO __all__ = ['Class'] #: documentation for the integer integer = 1 def raises(exc, func, *args, **kwds): """Raise AssertionError if ``func(*args, **kwds)`` does not raise *exc*.""" pass class CustomEx(Exception): """My custom exception.""" def f(self): ""...
222
4,632
sphinx
tests/roots/test-root/special/code.py
.py
print('line 1') print('line 2')
3
32
sphinx
tests/roots/test-ext-coverage/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage'] coverage_modules = [ 'grog', ] coverage_ignore_pyobjects = [ r'^grog\.coverage_ignored(\..*)?$', r'\.Ignored$', r'\.Documented\.ignored\d$', ]
16
303
sphinx
tests/roots/test-ext-coverage/grog/coverage_ignored.py
.py
class Documented: """Documented""" def ignored1(self): pass def ignored2(self): pass def not_ignored1(self): pass def not_ignored2(self): pass class Ignored: pass class NotIgnored: pass
23
254
sphinx
tests/roots/test-ext-coverage/grog/coverage_missing.py
.py
"""This module is intentionally not documented.""" class Missing: """An undocumented class.""" def missing_a(self): """An undocumented method."""
9
165
sphinx
tests/roots/test-html_assets/conf.py
.py
project = 'Sphinx' version = '1.4.4' html_static_path = ['static', 'subdir'] html_extra_path = ['extra', 'subdir'] html_css_files = [ 'css/style.css', ( 'https://example.com/custom.css', {'title': 'title', 'media': 'print', 'priority': 400}, ), ] html_js_files = [ 'js/custom.js', ( ...
21
464
sphinx
tests/roots/test-build-text/conf.py
.py
source_suffix = { '.txt': 'restructuredtext', } exclude_patterns = ['_build']
5
82
sphinx
tests/roots/test-inheritance/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['sphinx.ext.inheritance_diagram']
7
132
sphinx
tests/roots/test-inheritance/dummy/test_nested.py
.py
"""Test with nested classes.""" class A: class B: # NoQA: D106 pass class C(A.B): pass
11
108
sphinx
tests/roots/test-inheritance/dummy/test.py
.py
r"""Test with a class diagram like this:: A / \ B C / \ / \ E D F """ # NoQA: D208 class A: pass class B(A): pass class C(A): pass class D(B, C): pass class E(B): pass class F(C): pass
34
275
sphinx
tests/test_directives/test_directive_only.py
.py
"""Test the only directive with the test root.""" from __future__ import annotations import re from typing import TYPE_CHECKING import pytest from docutils import nodes if TYPE_CHECKING: from typing import Any from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('text', testroot='directive-o...
64
2,146
sphinx
tests/test_directives/test_directive_other.py
.py
"""Test the other directives.""" from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing import restructuredtext from sphinx.testing.util import assert_node from tests.utils import extract_...
215
7,303
sphinx
tests/test_directives/test_directive_productionlist.py
.py
"""Tests the productionlist directive.""" from __future__ import annotations import pytest from docutils import nodes from sphinx.addnodes import pending_xref from sphinx.testing import restructuredtext from sphinx.testing.util import SphinxTestApp, assert_node, etree_parse TYPE_CHECKING = False if TYPE_CHECKING: ...
154
7,343
sphinx
tests/test_directives/test_directives_no_typesetting.py
.py
"""Tests the directives""" from __future__ import annotations import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing import restructuredtext from sphinx.testing.util import assert_node TYPE_CHECKING = False if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp ty...
269
7,209
sphinx
tests/test_directives/test_directive_option.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'html', testroot='root', confoverrides={'option_emphasise_placeholders': True}, ) def test_option_emphasise_placeholders(app: Sphinx...
65
2,455
sphinx
tests/test_directives/test_directive_object_description.py
.py
"""Test object description directives.""" from __future__ import annotations from typing import TYPE_CHECKING import docutils.utils import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing import restructuredtext from sphinx.util.docutils import _parse_str_to_doctree from tests.util...
81
2,708
sphinx
tests/test_directives/test_directive_patch.py
.py
"""Test the patched directives.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.testing import restructuredtext from sphinx.testing.util import assert_node if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark....
147
4,724
sphinx
tests/test_directives/test_directive_code.py
.py
"""Test the code-block directive.""" from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING import pygments import pytest from docutils import nodes from sphinx.config import Config from sphinx.directives.code import LiteralIncludeReader from sphinx.testing.util import etree_pa...
634
22,968
sphinx
tests/js/roots/titles/relevance.py
.py
class Example: """Example class""" num_attribute = 5 text_attribute = 'string' relevance = 'testing' """attribute docstring"""
9
149
sphinx
tests/test_ext_napoleon/test_ext_napoleon_docstring.py
.py
"""Tests for :py:mod:`sphinx.ext.napoleon.docstring` module.""" from __future__ import annotations import re import zlib from collections import namedtuple from inspect import cleandoc from itertools import product from textwrap import dedent from types import SimpleNamespace from typing import TYPE_CHECKING from uni...
2,918
74,366
sphinx
tests/test_ext_napoleon/pep526_data_google.py
.py
"""Test module for napoleon PEP 526 compatibility with google style""" from __future__ import annotations module_level_var: int = 99 """This is an example module level variable""" class PEP526GoogleClass: """Sample class with PEP 526 annotations and google docstring. Attributes: attr1: Attr1 descri...
19
400
sphinx
tests/test_ext_napoleon/pep526_data_numpy.py
.py
"""Test module for napoleon PEP 526 compatibility with numpy style""" from __future__ import annotations module_level_var: int = 99 """This is an example module level variable""" class PEP526NumpyClass: """Sample class with PEP 526 annotations and numpy docstring Attributes ---------- attr1: ...
23
417
sphinx
tests/test_ext_napoleon/test_ext_napoleon.py
.py
"""Tests for :mod:`sphinx.ext.napoleon.__init__` module.""" from __future__ import annotations import functools from collections import namedtuple from unittest import mock import pytest from sphinx.application import Sphinx from sphinx.ext.napoleon import Config, _process_docstring, _skip_member, setup TYPE_CHECK...
299
8,251
sphinx
tests/test_ext_intersphinx/test_ext_intersphinx_cache.py
.py
"""Test the intersphinx extension.""" from __future__ import annotations import posixpath import re import shutil import zlib from http.server import BaseHTTPRequestHandler from io import BytesIO from typing import TYPE_CHECKING from sphinx.ext.intersphinx._shared import InventoryAdapter from sphinx.testing.util imp...
320
11,071
sphinx
tests/test_ext_intersphinx/test_ext_intersphinx.py
.py
"""Test the intersphinx extension.""" from __future__ import annotations import http.server import time from typing import TYPE_CHECKING from unittest import mock import pytest from docutils import nodes from sphinx import addnodes from sphinx._cli.util.errors import strip_escape_sequences from sphinx.builders.html...
946
36,174
sphinx
tests/test_domains/test_domain_js.py
.py
"""Tests the JavaScript Domain""" from __future__ import annotations from unittest.mock import Mock import docutils.utils import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_annotation, desc_content, desc_name, desc_parameter, desc_pa...
945
28,309
sphinx
tests/test_domains/test_domain_py_canonical.py
.py
"""Tests the Python Domain""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_sig_keyword, desc_sig_space, desc_signature, ) ...
117
3,389
sphinx
tests/test_domains/test_domain_c.py
.py
"""Tests the C Domain""" from __future__ import annotations import itertools import xml.etree.ElementTree as ET import zlib from typing import TYPE_CHECKING import pytest from sphinx import addnodes from sphinx.addnodes import ( desc, desc_content, desc_name, desc_parameter, desc_parameterlist, ...
1,423
43,714
sphinx
tests/test_domains/test_domain_py_fields.py
.py
"""Tests the Python Domain""" from __future__ import annotations import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_sig_keyword, desc_sig_punctuation, desc_sig_space, ...
612
18,255
sphinx
tests/test_domains/test_domain_std.py
.py
"""Tests the std domain""" from __future__ import annotations from typing import TYPE_CHECKING from unittest import mock import pytest from docutils import nodes from docutils.nodes import definition, definition_list, definition_list_item, term from sphinx import addnodes from sphinx.addnodes import ( desc, ...
612
18,281
sphinx
tests/test_domains/test_domain_py_pyfunction.py
.py
"""Tests the Python Domain""" from __future__ import annotations import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_optional, desc_parameter, desc_parameterlist, desc...
896
24,943
sphinx
tests/test_domains/test_domain_rst.py
.py
"""Tests the reStructuredText domain.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_signature, ) from sphinx.domains.rst import ...
290
7,497
sphinx
tests/test_domains/test_domain_py_pyobject.py
.py
"""Tests the Python Domain""" from __future__ import annotations import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_parameterlist, desc_sig_keyword, desc_sig_punctuation,...
1,159
36,388
sphinx
tests/test_domains/test_domain_cpp.py
.py
"""Tests the C++ Domain""" from __future__ import annotations import itertools import re import zlib from typing import TYPE_CHECKING import pytest import sphinx.domains.cpp from sphinx import addnodes from sphinx.addnodes import ( desc, desc_content, desc_name, desc_parameter, desc_parameterlis...
2,476
86,322
sphinx
tests/test_domains/test_domain_py.py
.py
"""Tests the Python Domain""" from __future__ import annotations import re from unittest.mock import Mock import docutils.utils import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_annotation, desc_content, desc_name, desc_parameter, d...
1,903
71,210
sphinx
tests/test_intl/test_locale.py
.py
"""Test locale.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx import locale if TYPE_CHECKING: from collections.abc import Callable, Iterator from pathlib import Path from sphinx.testing.util import SphinxTestApp @pytest.fixture(autouse=True) def _cl...
90
2,961
sphinx
tests/test_intl/test_catalogs.py
.py
"""Test the base build process.""" from __future__ import annotations import shutil from pathlib import Path from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from collections.abc import Iterator from sphinx.testing.fixtures import _app_params from sphinx.testing.util import SphinxTestAp...
95
3,051
sphinx
tests/test_intl/test_intl.py
.py
"""Test message patching for internationalization purposes. Runs the text builder in the test root. """ from __future__ import annotations import os import re import shutil import time from typing import TYPE_CHECKING import pygments import pytest from babel.messages import mofile, pofile from babel.messages.catalo...
2,145
70,345
sphinx
tests/test_ext_autosummary/test_ext_autosummary_imports.py
.py
"""Test autosummary for import cycles.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx import addnodes from sphinx.ext.autosummary import autosummary_table from sphinx.testing.util import assert_node from tests.utils import extract_node i...
80
2,247
sphinx
tests/test_ext_autosummary/test_ext_autosummary.py
.py
"""Test the autosummary extension.""" from __future__ import annotations import sys from contextlib import chdir from io import StringIO from typing import TYPE_CHECKING from unittest.mock import Mock, patch import pytest from docutils import nodes from sphinx import addnodes from sphinx.ext.autosummary import ( ...
1,001
31,401
sphinx
tests/test_config/test_config.py
.py
"""Test the sphinx.config.Config class.""" from __future__ import annotations import pickle from collections import Counter from typing import TYPE_CHECKING, Any from unittest import mock import pytest import sphinx from sphinx.config import ( ENUM, Config, check_confval_types, is_serializable, ) fr...
811
25,757
sphinx
tests/test_config/test_copyright.py
.py
"""Test copyright year adjustment""" from __future__ import annotations import time from typing import TYPE_CHECKING import pytest from sphinx.config import ( Config, correct_copyright_year, evaluate_copyright_placeholders, ) from sphinx.testing.util import SphinxTestApp if TYPE_CHECKING: from coll...
252
8,369
sphinx
tests/test__cli/test__cli_util_errors.py
.py
from __future__ import annotations import itertools import operator from typing import TYPE_CHECKING from sphinx._cli.util.colour import blue, reset from sphinx._cli.util.errors import strip_escape_sequences if TYPE_CHECKING: from collections.abc import Sequence from typing import Final CURSOR_UP: Final[str...
82
2,877
sphinx
tests/test_writers/test_writer_text.py
.py
"""Test the LaTeX writer""" from __future__ import annotations import pytest from docutils.utils import column_width from sphinx.writers.text import TextWrapper find_break_end = TextWrapper._find_break_end @pytest.mark.parametrize( # glyph of column width 0 'glyph', ['', '\N{COMBINING TILDE}'], ) def ...
184
6,216
sphinx
tests/test_writers/test_api_translator.py
.py
"""Test the Sphinx API for translator.""" from __future__ import annotations import sys from typing import TYPE_CHECKING import pytest from sphinx.testing.util import SphinxTestApp if TYPE_CHECKING: from collections.abc import Iterator from pathlib import Path from sphinx.testing.util import SphinxTes...
104
3,706
sphinx
tests/test_writers/test_docutilsconf.py
.py
"""Test docutils.conf support for several writers.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.testing.util import assert_node from sphinx.util.docutils import patch_docutils if TYPE_CHECKING: from sphinx.application import Sphinx ...
51
1,278
sphinx
tests/test_writers/test_writer_latex.py
.py
"""Test the LaTeX writer""" from __future__ import annotations import pytest from sphinx.writers.latex import rstdim_to_latexdim def test_rstdim_to_latexdim() -> None: # Length units docutils supported # https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#length-units assert rstdim_to_la...
31
1,154
sphinx
tests/test_pycode/test_pycode.py
.py
"""Test pycode.""" from __future__ import annotations import sys from importlib.machinery import SourceFileLoader from pathlib import Path import pytest import sphinx from sphinx.errors import PycodeError from sphinx.pycode import ModuleAnalyzer SPHINX_MODULE_PATH = Path(sphinx.__file__).resolve().with_suffix('.py...
196
6,464
sphinx
tests/test_pycode/test_pycode_parser.py
.py
"""Test pycode.parser.""" from __future__ import annotations from sphinx.pycode.parser import Parser from sphinx.util.inspect import signature_from_str def test_comment_picker_basic() -> None: source = ( 'a = 1 + 1 #: assignment\n' 'b = 1 +\\\n 1 #: assignment including a CR\n' 'c ...
598
16,317
sphinx
tests/test_pycode/test_pycode_ast.py
.py
"""Test pycode.ast""" from __future__ import annotations import ast import pytest from sphinx.pycode.ast import unparse as ast_unparse @pytest.mark.parametrize( ('source', 'expected'), [ ('a + b', 'a + b'), # Add ('a and b', 'a and b'), # And ...
76
3,622
sphinx
tests/test_util/typing_test_data.py
.py
from inspect import Signature from numbers import Integral from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, TypeVar, Union def f0(x: int, y: Integral) -> None: pass def f1(x: list[int]) -> List[int]: pass T = TypeVar('T') T_co = TypeVar('T_co', covariant=True) T_contra = TypeVar('T_...
134
2,085
sphinx
tests/test_util/test_util_uri.py
.py
from __future__ import annotations from sphinx.util._uri import encode_uri def test_encode_uri() -> None: expected = ( 'https://ru.wikipedia.org/wiki/%D0%A1%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_' '%D1%83%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F_' '%D0%B1%D0%B0%D0%B7%D0%B0%D0%B...
24
892
sphinx
tests/test_util/test_util_inspect.py
.py
"""Tests util.inspect functions.""" from __future__ import annotations import ast import datetime import enum import functools import types from inspect import Parameter from typing import Callable, List, Optional, Union # NoQA: UP035 import pytest from sphinx.util import inspect from sphinx.util.inspect import ( ...
1,018
33,651
sphinx
tests/test_util/test_util_inspect_py314.py
.py
# noqa: I002 as 'from __future__ import annotations' prevents Python 3.14 # forward references from causing issues, so we must skip it here. import pytest from sphinx.util import inspect from sphinx.util.typing import stringify_annotation try: from annotationlib import ForwardRef # type: ignore[import-not-found...
53
1,553
sphinx
tests/test_util/test_util_nodes.py
.py
"""Tests uti.nodes functions.""" from __future__ import annotations from textwrap import dedent from typing import TYPE_CHECKING, Any import pytest from docutils import frontend, nodes from docutils.parsers import rst from docutils.utils import new_document from sphinx.transforms import ApplySourceWorkaround from s...
276
7,942
sphinx
tests/test_util/test_util_images.py
.py
"""Test images util.""" from __future__ import annotations import pytest from sphinx.util.images import ( get_image_extension, get_image_size, guess_mimetype, parse_data_uri, ) TYPE_CHECKING = False if TYPE_CHECKING: from pathlib import Path GIF_FILENAME = 'img.gif' PNG_FILENAME = 'img.png' PDF...
101
3,306
sphinx
tests/test_util/test_util_i18n.py
.py
"""Test i18n util.""" from __future__ import annotations import datetime import os import time from pathlib import Path from typing import TYPE_CHECKING import pytest from babel.messages.mofile import read_mo from sphinx.errors import SphinxError from sphinx.util import i18n if TYPE_CHECKING: from sphinx.testi...
213
8,353
sphinx
tests/test_util/intersphinx_data.py
.py
from __future__ import annotations import zlib from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Final INVENTORY_V1: Final[bytes] = b"""\ # Sphinx inventory version 1 # Project: foo # Version: 1.0 module mod foo.html module.cls class foo.html """ INVENTORY_V2: Final[bytes] = b"""\ # Sphinx i...
74
2,280
sphinx
tests/test_util/test_util_display.py
.py
"""Tests util functions.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx._cli.util.errors import strip_escape_sequences from sphinx.util import logging from sphinx.util.display import ( SkipProgressMessage, display_chunk, progress_message, status_iter...
120
3,806
sphinx
tests/test_util/test_util_inventory.py
.py
"""Test inventory util functions.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest import sphinx.locale from sphinx.testing.util import SphinxTestApp from sphinx.util.inventory import InventoryFile, _InventoryItem from tests.test_util.intersphinx_data import ( INVENTORY_V1, ...
121
4,088
sphinx
tests/test_util/test_util.py
.py
"""Tests util functions.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest import sphinx.util from sphinx._cli.util.errors import strip_escape_sequences from sphinx.deprecation import RemovedInSphinx10Warning from sphinx.util._files import DownloadFiles, FilenameUniqDict from sphi...
70
2,292
sphinx
tests/test_util/test_util_logging.py
.py
"""Test logging util.""" from __future__ import annotations import os from contextlib import contextmanager from pathlib import Path from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx._cli.util.errors import strip_escape_sequences from sphinx.cmd.build import build_main from sphin...
426
15,170
sphinx
tests/test_util/test_util_matching.py
.py
"""Tests sphinx.util.matching functions.""" from __future__ import annotations from typing import TYPE_CHECKING from sphinx.util.matching import Matcher, compile_matchers, get_matching_files if TYPE_CHECKING: from pathlib import Path def test_compile_matchers() -> None: # exact matching pat = compile_...
322
8,549
sphinx
tests/test_util/test_util_fileutil.py
.py
"""Tests sphinx.util.fileutil functions.""" from __future__ import annotations import re from pathlib import Path from typing import TYPE_CHECKING from unittest import mock import pytest from sphinx._cli.util.errors import strip_escape_sequences from sphinx.jinja2glue import BuiltinTemplateLoader from sphinx.util.f...
172
6,236
sphinx
tests/test_util/test_util_docutils_sphinx_directive.py
.py
from __future__ import annotations from types import SimpleNamespace from docutils import nodes from docutils.parsers.rst.languages import en as english from docutils.parsers.rst.states import ( Inliner, RSTState, RSTStateMachine, state_classes, ) from docutils.statemachine import StringList from docu...
151
4,976
sphinx
tests/test_util/test_util_docutils.py
.py
"""Tests util.utils functions.""" from __future__ import annotations import os from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.util.docutils import ( SphinxFileOutput, SphinxTranslator, docutils_namespace, new_document, register_node, ) if TYPE_CHECKING: ...
104
3,126
sphinx
tests/test_util/test_util_template.py
.py
"""Tests sphinx.util.template functions.""" from __future__ import annotations from sphinx.util.template import ReSTRenderer def test_ReSTRenderer_escape() -> None: r = ReSTRenderer() template = '{{ "*hello*" | e }}' assert r.render_string(template, {}) == r'\*hello\*' def test_ReSTRenderer_heading() ...
30
934
sphinx
tests/test_util/test_util_rst.py
.py
"""Tests sphinx.util.rst functions.""" from __future__ import annotations from docutils.statemachine import StringList from jinja2 import Environment from sphinx.util.rst import ( _append_epilogue, _prepend_prologue, escape, heading, textwidth, ) def test_escape() -> None: assert escape(':r...
188
6,017
sphinx
tests/test_util/test_util_docstrings.py
.py
"""Test sphinx.util.docstrings.""" from __future__ import annotations from sphinx.util.docstrings import ( prepare_commentdoc, prepare_docstring, separate_metadata, ) def test_separate_metadata() -> None: # metadata only text = ':meta foo: bar\n:meta baz:\n' docstring, metadata = separate_me...
85
2,864
sphinx
tests/test_util/test_util_lines.py
.py
from __future__ import annotations import pytest from sphinx.util._lines import parse_line_num_spec def test_parse_line_num_spec() -> None: assert parse_line_num_spec('1,2,3', 10) == [0, 1, 2] assert parse_line_num_spec('4, 5, 6', 10) == [3, 4, 5] assert parse_line_num_spec('-4', 10) == [0, 1, 2, 3] ...
25
1,062
sphinx
tests/test_util/test_util_typing.py
.py
"""Tests util.typing functions.""" from __future__ import annotations import ctypes import dataclasses import sys import typing as t import zipfile from collections import abc from contextvars import Context, ContextVar, Token from enum import Enum from io import ( BufferedRandom, BufferedReader, Buffered...
1,030
40,472
sphinx
tests/test_util/test_util_importer.py
.py
"""Test sphinx.util._importer.""" from __future__ import annotations import pytest from sphinx.errors import ExtensionError from sphinx.util._importer import import_object def test_import_object() -> None: module = import_object('sphinx') assert module.__name__ == 'sphinx' module = import_object('sphi...
29
880
sphinx
tests/test_markup/test_metadata.py
.py
"""Test our handling of metadata in files with bibliographic metadata.""" # adapted from an example of bibliographic metadata at # https://docutils.sourceforge.io/docs/user/rst/demo.txt from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util i...
53
2,041
sphinx
tests/test_markup/test_smartquotes.py
.py
"""Test smart quotes.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.testing.util import etree_parse if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'html', testroot='smartquotes', freshenv=True, ) def test_bas...
172
4,553
sphinx
tests/test_markup/test_parser.py
.py
"""Tests parsers module.""" from __future__ import annotations from typing import TYPE_CHECKING from unittest.mock import Mock, patch import pytest from sphinx.parsers import RSTParser from sphinx.util.docutils import new_document if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.s...
71
2,374
sphinx
tests/test_markup/test_markup.py
.py
"""Test various Sphinx-specific markup extensions.""" from __future__ import annotations import re from types import SimpleNamespace import pytest from docutils import nodes, utils from docutils.parsers.rst import Parser as RstParser from sphinx import addnodes from sphinx.builders.latex import LaTeXBuilder from sp...
790
28,313
sphinx
tests/test_environment/test_environment_toctree.py
.py
"""Test the sphinx.environment.adapters.toctree.""" from __future__ import annotations from typing import TYPE_CHECKING import docutils import pytest from docutils import nodes from docutils.nodes import bullet_list, list_item, literal, reference, title from sphinx import addnodes from sphinx.addnodes import compac...
1,105
34,108
sphinx
tests/test_environment/test_environment.py
.py
"""Test the BuildEnvironment class.""" from __future__ import annotations import shutil from pathlib import Path from typing import TYPE_CHECKING import pytest from sphinx._cli.util.errors import strip_escape_sequences from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.builders.latex import LaTeXBui...
234
7,647
sphinx
tests/test_environment/test_environment_indexentries.py
.py
"""Test the sphinx.environment.adapters.indexentries.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.environment.adapters.indexentries import IndexEntries from sphinx.testing import restructuredtext if TYPE_CHECKING: from sphinx.testing.util import SphinxTestAp...
292
8,991
sphinx
tests/test_environment/test_environment_record_dependencies.py
.py
"""Tests for ``record_dependencies``.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='environment-record-dependencies') def test_record_dependencies_cleared(app: SphinxTes...
18
482
sphinx
tests/test_builders/xpath_util.py
.py
from __future__ import annotations import re import textwrap from typing import TYPE_CHECKING from xml.etree.ElementTree import tostring if TYPE_CHECKING: import os from collections.abc import Callable, Iterable, Sequence from xml.etree.ElementTree import Element, ElementTree def _get_text(node: Element...
86
2,644
sphinx
tests/test_builders/test_build_html_image.py
.py
from __future__ import annotations import re from pathlib import Path from typing import TYPE_CHECKING import docutils import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.usefixtures('_http_teapot') @pytest.mark.sphinx('html', testroot='images') def test_html_remote_image...
115
3,789
sphinx
tests/test_builders/xpath_data.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Final FIGURE_CAPTION: Final[str] = './/figure/figcaption/p'
9
172
sphinx
tests/test_builders/test_incremental_reading.py
.py
"""Test the Builder class.""" from __future__ import annotations import sys from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'dummy', testroot='root', srcdir='test_builder', freshenv=True, ) def test_incremental...
60
1,615