tests.sphinx.test_sphinx_todos moduleΒΆ
Tests for the todolist deduplication hook and the unrendered-todo check.
- tests.sphinx.test_sphinx_todos.TODO_SOURCE_RE = re.compile('<p class="todo-source">\\(The <a class="reference internal" href="([^"]+)">.*?located in (.*?), line (\\d+)\\.\\)</p>', re.DOTALL)ΒΆ
Captures the page, the origin and the line of every rendered todo entry.
sphinx.ext.todoemits one such paragraph per entry it puts on atodolist, so counting them counts the entries.
- tests.sphinx.test_sphinx_todos.COMPOST_MODULE = '"""Turn fallen fruit into compost.\n\n.. todo::\n Turn the heap once a week.\n"""\n'ΒΆ
A module docstring with a todo on its third line.
- tests.sphinx.test_sphinx_todos.GRAFTING_MODULE = '"""Fruit grafting."""\n\n\ndef _graft(branch):\n """Join ``branch`` to a rootstock.\n\n .. todo::\n Seal the cut with wax.\n """\n return branch\n'ΒΆ
A module whose only todo sits in a private function, which
:members:skips.
- tests.sphinx.test_sphinx_todos.VARIETIES_MODULE = '"""Fruit varieties."""\n\n\nclass Fruit:\n """A fruit."""\n\n\nAPPLE = Fruit()\n"""A crisp apple.\n\n.. todo::\n Pick the reddest one first.\n"""\n\nAPPLE.__doc__ = """A crisp apple.\n\n.. todo::\n Pick the reddest one first.\n"""\n'ΒΆ
A module whose attribute docstring the instance carries too.
A registry of documented instances copies it this way, so that autodoc finds the docstring under a path that re-exports the attribute, where no source carries it. autodoc labels each rendering with the path it documented.
- tests.sphinx.test_sphinx_todos.VARIETIES_INIT = '"""An orchard."""\n\nfrom .varieties import APPLE\n\n__all__ = ["APPLE"]\n'ΒΆ
A package re-exporting the attribute of
VARIETIES_MODULE.
- tests.sphinx.test_sphinx_todos.BOWLS_MODULE = '"""Fruit bowls."""\n\n\nclass Fruit:\n """A fruit."""\n\n\nBOWL = Fruit()\n\nPEAR = BOWL\n"""A pear.\n\n.. todo::\n Wait for autumn.\n"""\n\nQUINCE = BOWL\n"""A quince.\n\n.. todo::\n Cook it first.\n"""\n'ΒΆ
Two attributes bound to one object, each with a todo of its own on one line.
- tests.sphinx.test_sphinx_todos.UNRENDERED_RE = re.compile('(\\S+):(\\d+): WARNING: click_extra\\.sphinx: no page renders the docstring of (\\S+), so no todolist can list this todo\\.')ΒΆ
Captures the file, the line and the owner of every unrendered-todo warning.
- tests.sphinx.test_sphinx_todos.build_project(tmp_path, package, pages, *, files=None, conf=(), dedupe=None, todo_extension=True)[source]ΒΆ
Build a throwaway project documenting
package, and return the build.pagesmaps a docname to its reStructuredText body. Atodospage carrying thetodolistis always appended, and every page is wired into the root toctree.packagenames the generated package, and must differ between tests: the modules are imported by autodoc into the running interpreter, wheresys.moduleswould otherwise serve the first testβs copy to every later one.filesmaps a path inside the package to its source, written over the orchardβs own__init__.pyandharvest.py.confappends lines to the generatedconf.py.Returns the output directory, the warning stream and the exit status.
- tests.sphinx.test_sphinx_todos.build_orchard(tmp_path, package, pages, **options)[source]ΒΆ
Build a project with
build_project, and return its todo entries.Returns the
(page, origin, line)triples thetodolistpage rendered, in document order.
- tests.sphinx.test_sphinx_todos.unrendered_todos(warnings)[source]ΒΆ
Return the
(file name, line, owner)of each unrendered-todo warning.
- tests.sphinx.test_sphinx_todos.automodule(target, no_index=False)[source]ΒΆ
Render an
automoduleblock fortarget.
- tests.sphinx.test_sphinx_todos.fake_node(source, line=1)[source]ΒΆ
A
todonode reduced to the two attributes the identity helpers read.
- tests.sphinx.test_sphinx_todos.test_todo_identity_ignores_the_import_path_of_a_docstring()[source]ΒΆ
Two renderings of one docstring share an identity whatever reached it.
- tests.sphinx.test_sphinx_todos.test_todo_identity_reads_the_source_form_without_a_file()[source]ΒΆ
A source autodoc wrote without a file yields its label like one with a file.
- tests.sphinx.test_sphinx_todos.test_is_reexport(source, expected)[source]ΒΆ
Only a docstring reached through a package
__init__ranks as re-exported.
- tests.sphinx.test_sphinx_todos.test_full_api_page_and_feature_page_yield_one_entry_each(tmp_path)[source]ΒΆ
A module documented twice across pages lists each todo once.
- tests.sphinx.test_sphinx_todos.test_reexported_members_yield_one_entry_each(tmp_path)[source]ΒΆ
A member documented under both its package and its module lists once.
- tests.sphinx.test_sphinx_todos.test_surviving_entry_attributes_to_the_defining_module(tmp_path)[source]ΒΆ
The kept rendering names the module defining the object, not the package.
- tests.sphinx.test_sphinx_todos.test_reexported_attribute_yields_one_entry(tmp_path)[source]ΒΆ
An attribute documented under its package and its module lists once.
The two renderings of its docstring carry different labels, the paths autodoc documented: only the object behind both labels matches them.
- tests.sphinx.test_sphinx_todos.test_attributes_sharing_an_object_keep_an_entry_each(tmp_path)[source]ΒΆ
Two docstrings of one object keep their entries, though the object matches.
- tests.sphinx.test_sphinx_todos.test_dedupe_switched_off_restores_every_rendering(tmp_path)[source]ΒΆ
click_extra_dedupe_todos = Falsegives Sphinxβs raw output back.
- tests.sphinx.test_sphinx_todos.test_distinct_todos_all_survive(tmp_path)[source]ΒΆ
Deduplication collapses repeats, never two different directives.
- tests.sphinx.test_sphinx_todos.test_build_succeeds_without_the_todo_extension(tmp_path)[source]ΒΆ
The hook is inert on a project that never registered the todo domain.
- tests.sphinx.test_sphinx_todos.test_sort_todos_orders_the_domain_by_page()[source]ΒΆ
Entries merged out of page order, as a parallel read does, come back sorted.
- tests.sphinx.test_sphinx_todos.test_sort_todos_is_inert_without_entries(domains)[source]ΒΆ
A project with no todo domain, or no todo in it, is left as it was.
- tests.sphinx.test_sphinx_todos.test_docstring_todos(source, expected)[source]ΒΆ
Each todo is found at its line, under the path autodoc labels it with.
- tests.sphinx.test_sphinx_todos.test_docstring_todos_rejects_invalid_source()[source]ΒΆ
A module that does not parse raises, for the caller to skip it.
- tests.sphinx.test_sphinx_todos.test_package_modules_walks_without_importing(tmp_path, monkeypatch)[source]ΒΆ
Every module of a package is found, private ones included, none imported.
- tests.sphinx.test_sphinx_todos.test_unrendered_todos_warn_at_their_line(tmp_path)[source]ΒΆ
A todo in a docstring no page renders is reported at its own line.
- tests.sphinx.test_sphinx_todos.test_rendered_todos_do_not_warn(tmp_path)[source]ΒΆ
No todo a page renders is reported, a re-exported one included.
- tests.sphinx.test_sphinx_todos.test_todo_rendered_under_another_path_does_not_warn(tmp_path)[source]ΒΆ
A docstring autodoc labels with another path still counts as rendered.
With its
__module__overridden,pickis labeled with the path of the package, not with the path of the module that defines it.