Skip to content

Commit f07862c

Browse files
committed
Add a warning about nested classes and functions
1 parent ec4021c commit f07862c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/doctest.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,15 @@ 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+
.. warning::
354+
355+
Only classes and functions defined at the module level (or inside other
356+
classes) are automatically discovered by ``doctest``.
357+
358+
Classes or functions defined inside functions cannot be discovered,
359+
because their definitions depend on the runtime state of the enclosing
360+
function. To make their doctests discoverable, define them outside of
361+
the enclosing function.
353362

354363
.. _doctest-finding-examples:
355364

0 commit comments

Comments
 (0)