From: Bartosz Sławecki Date: Mon, 18 Aug 2025 14:58:23 +0000 (+0200) Subject: gh-44538: Mention nested classes/functions in doctest docs (GH-137870) X-Git-Tag: v3.15.0a1~654 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=138ed6db9f89171983dc32af4e7ad2e73d46a940;p=thirdparty%2FPython%2Fcpython.git gh-44538: Mention nested classes/functions in doctest docs (GH-137870) --- diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index 5a2c6bdd27c3..02b73ccd3f3d 100644 --- a/Doc/library/doctest.rst +++ b/Doc/library/doctest.rst @@ -350,6 +350,13 @@ searches them recursively for docstrings, which are then scanned for tests. Any classes found are recursively searched similarly, to test docstrings in their contained methods and nested classes. +.. note:: + + ``doctest`` can only automatically discover classes and functions that are + defined at the module level or inside other classes. + + Since nested classes and functions only exist when an outer function + is called, they cannot be discovered. Define them outside to make them visible. .. _doctest-finding-examples: