bpo-30523 added a new --list-cases command to regrtest to list test methods. It is able to list doctest tests in test_builtins, but not in test_extcall.
test_builtin doctest tests:
haypo@selma$ ./python -m test test_builtin --list-cases|grep ^builtins
builtins.bin
builtins.float.as_integer_ratio
...
test_builtins works because it uses:
def load_tests(loader, tests, pattern):
from doctest import DocTestSuite
tests.addTest(DocTestSuite(builtins))
return tests
Listing test methods of test_extcall doesn't work, the following command has no output (but succeed):
./python -m test test_extcall --list-cases
test_extcall uses:
def test_main():
support.run_doctest(sys.modules[__name__], True)
I see two options:
* Replace support.run_doctest() with doctest.DocTestSuite() in all tests
* Enhance --list-cases to discover doctests. support.run_doctest() calls doctest.testmod(), but doctest.testmod() has no API to list tests. testmod() lists tests and directly runs them. Maybe --list-cases can reuse doctest.DocTestSuite(), I don't know.