Skip to content

Commit 138ed6d

Browse files
authored
gh-44538: Mention nested classes/functions in doctest docs (GH-137870)
1 parent 83387e0 commit 138ed6d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/doctest.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ searches them recursively for docstrings, which are then scanned for tests.
350350
Any classes found are recursively searched similarly, to test docstrings in
351351
their contained methods and nested classes.
352352

353+
.. note::
354+
355+
``doctest`` can only automatically discover classes and functions that are
356+
defined at the module level or inside other classes.
357+
358+
Since nested classes and functions only exist when an outer function
359+
is called, they cannot be discovered. Define them outside to make them visible.
353360

354361
.. _doctest-finding-examples:
355362

0 commit comments

Comments
 (0)