Skip to content

regrtest: add --list-cases option to only display test case identifiers #74708

Closed

Description

@vstinner
BPO 30523
Nosy @vstinner, @rbtcollins, @ezio-melotti, @voidspace, @serhiy-storchaka, @JulienPalard, @mlouielu
PRs
  • bpo-30523: unittest: add --list-tests option #1885
  • bpo-30523: regrtest: Add --list-cases option #2238
  • bpo-30523: Add --list-cases unittest #2243
  • [3.6] Synchronize libregrtest from master to 3.6 #2244
  • [2.7] bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest #2249
  • [3.5] bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest #2250
  • bpo-30523: regrtest --list-cases now supports --match #2401
  • [3.6] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master #2441
  • [3.5] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master #2442
  • [2.7] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master #2444
  • 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-06-26.09:47:46.672>
    created_at = <Date 2017-05-31.09:22:37.791>
    labels = ['3.7', 'type-feature', 'tests']
    title = 'regrtest: add --list-cases option to only display test case identifiers'
    updated_at = <Date 2017-06-27.14:56:45.897>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-06-27.14:56:45.897>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-06-26.09:47:46.672>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2017-05-31.09:22:37.791>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30523
    keywords = []
    message_count = 26.0
    messages = ['294825', '294828', '294829', '294830', '294840', '295084', '295087', '295146', '295166', '295500', '296158', '296170', '296175', '296176', '296177', '296180', '296189', '296201', '296207', '296208', '296863', '296864', '296884', '297035', '297042', '297045']
    nosy_count = 7.0
    nosy_names = ['vstinner', 'rbcollins', 'ezio.melotti', 'michael.foord', 'serhiy.storchaka', 'mdk', 'louielu']
    pr_nums = ['1885', '2238', '2243', '2244', '2249', '2250', '2401', '2441', '2442', '2444']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue30523'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

    Activity

    1. vstinner commented on May 31, 2017

      @vstinner
      MemberAuthor

      Attached pull requests adds a --list-tests option to only display the list of test names, don't run tests.

      It's a first step to implement the issue bpo-29512: "regrtest refleak: implement bisection feature".

    2. vstinner commented on May 31, 2017

      @vstinner
      MemberAuthor

      Maybe the feature already exists but I failed to find it. Since I'm suprised that nobody implements that before (in unittest), I wait for a first feedback before starting to document the new feature and to write an unit test for it.

      support.run_unittest() doesn't use unittest.main() and so don't support the new --list-tests option.

    3. vstinner commented on May 31, 2017

      @vstinner
      MemberAuthor

      I wrote this patch because I'm trying to find which test of test_threading leaks a reference:

      ./python -m test -R 3:3 test_threading

      Usually, I modify Lib/test/test_threading.py to remove tests one by one. I "bisect" the test manually. But this process is slow and painful, and it seems like we have many tests which leak references!

    4. JulienPalard commented on May 31, 2017

      @JulienPalard
      Member

      If it can be of any help, pytest have a "pytest --collect-only", it may make sense to use the same option name for consistency. I also though about "--dry-run" but I still prefer --list-tests or --collect-only.

    5. vstinner commented on May 31, 2017

      @vstinner
      MemberAuthor
    6. serhiy-storchaka commented on Jun 3, 2017

      @serhiy-storchaka
      Member

      How to use this feature? "./python -m unittest --list-tests" produces nothing.

    7. JulienPalard commented on Jun 3, 2017

      @JulienPalard
      Member

      It works in "discover" mode, I tested:

      ./python -m unittest discover ./Lib/unittest/test/ --list-tests

      and it worked.

      So maybe the --list-tests should be moved to _getDiscoveryArgParser?

      Also spotted that tests are printed on stderr, typically when the users asks for something, it has to be printed to stdout. Typically usages are written on stderr in case of error, but on stdout when explicitly asked via --help, see:

      $ ./python -m unittest discover ./Lib/unittest/test/ --tabayo | wc
      usage: python -m unittest discover [-h] [-v] [-q] [--locals] [-f] [-c] [-b]
                                         [-s START] [-p PATTERN] [-t TOP]
                                         [--list-tests]
      python -m unittest discover: error: unrecognized arguments: --tabayo
            0       0       0
      $ ./python -m unittest discover ./Lib/unittest/test/ --help | wc
           23     129    1110
    8. vstinner commented on Jun 4, 2017

      @vstinner
      MemberAuthor

      I used ./python -m test Lib/test/test_threading.py --list-tests.

      I would like to be able to use this feature in regrtest too:

      ./python -m test test_threading --list-tests

      Sadly, this option already exists and only return test files, not test
      methods.

    9. serhiy-storchaka commented on Jun 5, 2017

      @serhiy-storchaka
      Member

      I concur with Julien, the result should be printed to stdout.

      I tried:

      $ ./python -m unittest test.test_builtin --list-tests
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      test.test_builtin.BuiltinTest.test_abs
      test.test_builtin.BuiltinTest.test_all
      ...
      
      $ ./python -m test.test_builtin --list-tests
      BuiltinTest.test_abs
      BuiltinTest.test_all
      BuiltinTest.test_any
      ...
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest
      doctest.DocTestCase.runTest

      All these doctest.DocTestCase.runTest look useless.

      But "./python -m unittest test.test_json --list-tests" and "./python -m test.test_json --list-tests" give the same output.

      "./python -m test.test_doctest --list-tests" and "./python -m test.test_tk --list-tests" run tests instead of listing them.

    10. serhiy-storchaka commented on Jun 9, 2017

      @serhiy-storchaka
      Member

      The main problem is doctests. Numerous "doctest.DocTestCase.runTest" look useless and confusing.

      Running tests instead of listing them is bad.

      It is not clear why in one cases --list-tests outputs full qualified test names, while in other cases it outputs only class and method names.

    11. mlouielu commented on Jun 16, 2017

      mlouielumannequin
      Mannequin

      Serhiy and Victor suggest moving this option to regrtest. open a new PR 2238 addressed this.

      Also, because moving into regrtest, some test that used requires will need to pass option when using it. e.g.:

        $ ./python -m test test.test_curses --list-cases -ucurses

      otherwise, it will just passout and do nothing (maybe it should warn user?)

    12. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      New changeset a49c935 by Victor Stinner (mlouielu) in branch 'master':
      bpo-30523: regrtest: Add --list-cases option (bpo-2238)
      a49c935

    13. 2 remaining items

    14. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      New changeset b0c58d3 by Victor Stinner (Louie Lu) in branch 'master':
      bpo-30523: Add --list-cases unittest (bpo-2243)
      b0c58d3

    15. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      I created bpo-30683: Enhance doctest support in regrtest --list-cases.

    16. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      New changeset a0ccc54 by Victor Stinner in branch '3.6':
      Synchronize libregrtest from master to 3.6 (bpo-2244)
      a0ccc54

    17. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      New changeset 24c2c20 by Victor Stinner in branch '2.7':
      bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest (bpo-2249)
      24c2c20

    18. changed the title [-]unittest: add --list-tests option to only display the list of test names, don't run tests[/-] [+]regrtest: add --list-cases option to only display test case identifiers[/+] on Jun 16, 2017
    19. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      On Python 2.7, listing *all* test cases with "./python -m test --list-cases" fails on the following test files:

      • test_multibytecodec_support
      • test_robotparser
      • test_xpickle

      regrtest of Python 2.7 uses the test_main() function of each test file, if the function is defined. Whereas --list-cases is more written as a raw discovery function listing all cases which inherit from unittest.TestCase. These 3 files have base test cases which are "abstract" or configured below.

      Options:

      • Modify --list-cases to tolerate failures and report them at exit
      • Modify these 3 tests to make them more "test discovery"-friendly
      • Use test_main() function if available but modify its behaviour to only list test cases, instead of running them

      I would prefer to limit changes in Python 2.7 branch, so IMHO the second option is the best: modify the 3 tests.

    20. vstinner commented on Jun 16, 2017

      @vstinner
      MemberAuthor

      New changeset 46e299c by Victor Stinner in branch '3.5':
      [3.5] bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest (bpo-2250)
      46e299c

    21. vstinner commented on Jun 26, 2017

      @vstinner
      MemberAuthor

      On Python 2.7, listing *all* test cases with "./python -m test --list-cases" fails on the following test files:

      I created bpo-30759: "[2.7] Fix python2 -m test --list-cases test_multibytecodec_support test_robotparser".

    22. vstinner commented on Jun 26, 2017

      @vstinner
      MemberAuthor

      regrtest now supports --list-cases and --matchfile features in 2.7, 3.5, 3.6 and master (future 3.7) branches, so I now close the issue.

      See bpo-30759 for the pending bug in Python 2.7. IMHO this bug is not a blocking feature, so it's ok to this close this issue.

      Thanks Serhiy Storchaka and Julien Palard for the feedback and reviews, thanks Louie Lu for the actual implementation, much simpler than what I expected ;-)

      These features already helped me a lot of identified reference leaks. So thank you all ;-)

    23. vstinner commented on Jun 26, 2017

      @vstinner
      MemberAuthor

      New changeset ace56d5 by Victor Stinner in branch 'master':
      bpo-30523: regrtest --list-cases --match (bpo-2401)
      ace56d5

    24. vstinner commented on Jun 27, 2017

      @vstinner
      MemberAuthor

      New changeset 35d2ca2 by Victor Stinner in branch '3.6':
      [3.6] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master (bpo-2441)
      35d2ca2

    25. vstinner commented on Jun 27, 2017

      @vstinner
      MemberAuthor

      New changeset de1850b by Victor Stinner in branch '3.5':
      [3.5] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master (bpo-2442)
      de1850b

    26. vstinner commented on Jun 27, 2017

      @vstinner
      MemberAuthor

      New changeset fea98bf by Victor Stinner in branch '2.7':
      [2.7] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master (bpo-2444)
      fea98bf

    27. 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