From 27a2152a9b976ea09bd6de02f44acef29581bd36 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 27 Aug 2025 16:01:55 +0200 Subject: [PATCH] [3.14] gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (#137918) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartosz Sławecki --- Doc/library/doctest.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index 82e570a2a85c..61463d6adcd1 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: -- 2.47.3