Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully qualified test name in failure output #58473

Closed
voidspace opened this issue Mar 12, 2012 · 8 comments
Closed

Fully qualified test name in failure output #58473

voidspace opened this issue Mar 12, 2012 · 8 comments
Assignees
Labels
3.11 only security fixes easy stdlib Python modules in the Lib dir

Comments

@voidspace
Copy link
Contributor

BPO 14265
Nosy @pitrou, @bitdancer, @voidspace, @asvetlov, @ethanfurman, @palaviv, @dignissimus
PRs
  • bpo-14265: Adds fully qualified test name to unittest output #32138
  • Files
  • 14265.patch
  • 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 = 'https://github.com/ethanfurman'
    closed_at = <Date 2022-03-29.15:03:07.473>
    created_at = <Date 2012-03-12.19:59:47.348>
    labels = ['easy', 'library', '3.11']
    title = 'Fully qualified test name in failure output'
    updated_at = <Date 2022-03-29.15:03:07.473>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2022-03-29.15:03:07.473>
    actor = 'asvetlov'
    assignee = 'ethan.furman'
    closed = True
    closed_date = <Date 2022-03-29.15:03:07.473>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2012-03-12.19:59:47.348>
    creator = 'michael.foord'
    dependencies = []
    files = ['42434']
    hgrepos = []
    issue_num = 14265
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['155467', '155468', '155746', '155754', '263193', '416098', '416116', '416265']
    nosy_count = 7.0
    nosy_names = ['pitrou', 'r.david.murray', 'michael.foord', 'asvetlov', 'ethan.furman', 'palaviv', 'sam_ezeh']
    pr_nums = ['32138']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue14265'
    versions = ['Python 3.11']

    @voidspace
    Copy link
    Contributor Author

    Somewhere in the failure message for tests Guido would like to see the fully qualified test name, suitable for copying and pasting into a test runner invocation for running just that test.

    @voidspace voidspace self-assigned this Mar 12, 2012
    @voidspace voidspace added the stdlib Python modules in the Lib dir label Mar 12, 2012
    @bitdancer
    Copy link
    Member

    +10 :)

    @pitrou
    Copy link
    Member

    pitrou commented Mar 14, 2012

    Which failure message are we talking about? regrtest? unittest?

    @bitdancer
    Copy link
    Member

    I'm pretty sure Michael is talking about unittest. Doing the same for regrtest would be interesting but not as important. (When I run individual tests from the Python test suite I generally use -m unittest to do it.)

    @palaviv
    Copy link
    Mannequin

    palaviv mannequin commented Apr 11, 2016

    Included is a patch with the suggested change.
    I changed the TestCase.__str__ method to:
    return "%s (%s.%s)" % (self._testMethodName, strclass(self.__class__), self._testMethodName)
    instead of
    return "%s (%s)" % (self._testMethodName, strclass(self.__class__))

    So now a failed test look like this:

    ======================================================================
    ERROR: test_error_handling (Lib.test.test_logging.StreamHandlerTest.test_error_handling)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/aviv/dev/cpython/Lib/test/test_logging.py", line 641, in test_error_handling
        self.assertIs(h.error_record, r)
    AttributeError: 'TestStreamHandler' object has no attribute 'error_record'

    @ethanfurman
    Copy link
    Member

    Hopefully somebody on the core-mentorship list can move this forward by converting to a PR and reviewing.

    If @palaviv is still active the review itself will still be useful.

    @ethanfurman ethanfurman added easy 3.11 only security fixes labels Mar 26, 2022
    @ethanfurman ethanfurman assigned ethanfurman and unassigned voidspace Mar 26, 2022
    @dignissimus
    Copy link
    Mannequin

    dignissimus mannequin commented Mar 27, 2022

    The provided patch wasn't entirely compatible with the current upstream code. I used the patch file to apply the changes to [Lib/unittest/case.py](https://github.com/python/cpython/blob/main/Lib/unittest/case.py), resolved the remaining conflicts with the patches to the test files and amended existing tests for the library.

    I updated the documentation for unittest to reflect the changes in behaviour.

    @asvetlov
    Copy link
    Contributor

    New changeset 755be9b by Sam Ezeh in branch 'main':
    bpo-14265: Adds fully qualified test name to unittest output (GH-32138)
    755be9b

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes easy stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants