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

Support telling TestResult objects a test run has finished #49978

Closed
rbtcollins opened this issue Apr 9, 2009 · 10 comments
Closed

Support telling TestResult objects a test run has finished #49978

rbtcollins opened this issue Apr 9, 2009 · 10 comments
Labels
stdlib Python modules in the Lib dir

Comments

@rbtcollins
Copy link
Member

BPO 5728
Nosy @warsaw, @rbtcollins, @voidspace
Files
  • start-stop-TestRun.patch
  • start-stop-TestRun.patch: version2.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 = None
    closed_at = <Date 2009-05-02.22:44:44.498>
    created_at = <Date 2009-04-09.12:15:23.264>
    labels = ['library']
    title = 'Support telling TestResult objects a test run has finished'
    updated_at = <Date 2009-05-02.22:44:44.453>
    user = 'https://github.com/rbtcollins'

    bugs.python.org fields:

    activity = <Date 2009-05-02.22:44:44.453>
    actor = 'michael.foord'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-05-02.22:44:44.498>
    closer = 'michael.foord'
    components = ['Library (Lib)']
    creation = <Date 2009-04-09.12:15:23.264>
    creator = 'rbcollins'
    dependencies = []
    files = ['13669', '13709']
    hgrepos = []
    issue_num = 5728
    keywords = ['patch']
    message_count = 10.0
    messages = ['85812', '85813', '85815', '85823', '85841', '86005', '86007', '86011', '86052', '86987']
    nosy_count = 5.0
    nosy_names = ['barry', 'rbcollins', 'michael.foord', 'olemis', 'dgou']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue5728'
    versions = ['Python 3.1', 'Python 2.7']

    @rbtcollins
    Copy link
    Member Author

    Original mail:
    JML's testtools has a TestResult subclass with a done() method. The
    reason for this method is to allow doing things after the last test has
    run. While a result can infer 'first test' it can't infer 'last test'
    without ugliness like __del__.

    Some uses for this are:

    • reporting summary data
    • closing external resources like log files, sockets to remote machines
      etc
    • <your idea here>

    This can be added quite safely I think - check for the attribute, and if
    present call it.

    done() could be spelt differently - I don't think anyone would care.
    testsFinished()
    finished()
    etc.

    @rbtcollins rbtcollins added the stdlib Python modules in the Lib dir label Apr 9, 2009
    @rbtcollins
    Copy link
    Member Author

    Now, some refinements, as usual (for me at least) when considering a
    feature like this from an upstream perspective, where one's immediate
    use cases are just special cases not general case, I've come up with
    some refinements.

    Firstly, I said you can infer starting. But its asymmetrical to have a
    'run is finished' method that unittest will call, and not a 'run is
    about to start' method too. So I think we should have two methods,
    paired. This will avoid people having to write inference code themselves
    every time.

    Secondly, TestCase.run(None) creates a result. I think it would be good
    to make a clear statement about who, and when should and will call these
    two new methods. Something like:

    "Whomever calls 'start' is responsible for calling 'done'." Concretely
    this means that when TestCase implicitly creates a TestResult, it will
    call start, and also call done.

    Thirdly, naming. I'm agnostic, but I'd lean towards something clear, and
    something that can't be easily confused with startTest/stopTest. e.g.
    'startTestRun' and 'stopTestRun' (just pluralising 'Test' to 'Tests'
    would be easily confusable).

    If this all makes sense, I'll write up some tests and put a patch
    together. I'm pasting this into the issue to, for folk that watch issues
    only :).

    @voidspace
    Copy link
    Contributor

    startTestRun and stopTestRun sound good to me.

    @dgou
    Copy link
    Mannequin

    dgou mannequin commented Apr 9, 2009

    Quite useful! Names are hard, but the ones proposed are pretty good.

    @rbtcollins
    Copy link
    Member Author

    I've written up a patch for this; it works with old result classes too.

    Hopefully the bugtracker will attach it in reply to this mail; if not
    I'll put in via the webui this evening.

    -Rob

    @warsaw
    Copy link
    Member

    warsaw commented Apr 15, 2009

    The patch looks fine to me, except that it's missing documentation
    updates. The feature and names are fine too.

    @rbtcollins
    Copy link
    Member Author

    On Wed, 2009-04-15 at 23:19 +0000, Barry A. Warsaw wrote:

    Barry A. Warsaw <barry@python.org> added the comment:

    The patch looks fine to me, except that it's missing documentation
    updates. The feature and names are fine too.

    Where do the docs go?

    -Rob

    @warsaw
    Copy link
    Member

    warsaw commented Apr 16, 2009

    On Apr 15, 2009, at 7:43 PM, Robert Collins wrote:

    Robert Collins <robertc@robertcollins.net> added the comment:

    On Wed, 2009-04-15 at 23:19 +0000, Barry A. Warsaw wrote:
    > Barry A. Warsaw <barry@python.org> added the comment:
    >
    > The patch looks fine to me, except that it's missing documentation
    > updates. The feature and names are fine too.

    Where do the docs go?

    Doc/library/unittest.rst

    @rbtcollins
    Copy link
    Member Author

    Updates - docs, and fixes a couple of stubbed out upcalls in the logging
    result put in while bootsrapping.

    @voidspace
    Copy link
    Contributor

    Committed in revision 72225.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants