Skip to content

Commit d188257

Browse files
[3.13] gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (GH-137917)
gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (cherry picked from commit 138ed6d) Co-authored-by: Bartosz Sławecki <[email protected]>
1 parent fc2e84f commit d188257

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
@@ -346,6 +346,13 @@ searches them recursively for docstrings, which are then scanned for tests.
346346
Any classes found are recursively searched similarly, to test docstrings in
347347
their contained methods and nested classes.
348348

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

350357
.. _doctest-finding-examples:
351358

0 commit comments

Comments
 (0)