Skip to content

Enhance doctest support in regrtest --list-cases #74868

Closed

Description

@vstinner
BPO 30683
Nosy @vstinner, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2017-08-11.00:04:07.406>
created_at = <Date 2017-06-16.11:40:34.595>
labels = ['3.7', 'type-feature', 'tests']
title = 'Enhance doctest support in regrtest --list-cases'
updated_at = <Date 2017-08-11.00:04:07.405>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2017-08-11.00:04:07.405>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2017-08-11.00:04:07.406>
closer = 'vstinner'
components = ['Tests']
creation = <Date 2017-06-16.11:40:34.595>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 30683
keywords = []
message_count = 4.0
messages = ['296179', '296203', '296205', '300140']
nosy_count = 2.0
nosy_names = ['vstinner', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue30683'
versions = ['Python 3.7']

Activity

  1. vstinner commented on Jun 16, 2017

    @vstinner
    MemberAuthor

    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.
  2. serhiy-storchaka commented on Jun 16, 2017

    @serhiy-storchaka
    Member

    Note that --match (and --matchfile) is ignored by doctests. I think this can cause a problem for bisect feature. After making --match working with doctests we can found a way to name doctests and list them.

  3. vstinner commented on Jun 16, 2017

    @vstinner
    MemberAuthor

    Note that --match (and --matchfile) is ignored by doctests, so technically, it seems that it's doable ;-)

    In test_os, --match works on doctest tests:

    haypo@selma$ ./python -m test -v test_builtin --match=builtins.hex
    (...)
    0:00:00 load avg: 0.28 [1/1] test_builtin
    hex (builtins)
    Doctest: builtins.hex ... ok

    ----------------------------------------------------------------------
    Ran 1 test in 0.002s
    (...)

  4. vstinner commented on Aug 11, 2017

    @vstinner
    MemberAuthor

    I have no idea how to implement this idea. I'm not interested to work on this topic, so I just close this issue. If someone wants to work on this topic, please open a new issue.

  5. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of lifetestsTests in the Lib/test dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions