Issue 5728: Support telling TestResult objects a test run has finished (original) (raw)

Created on 2009-04-09 12:15 by rbcollins, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (10)

msg85812 - (view)

Author: Robert Collins (rbcollins) * (Python committer)

Date: 2009-04-09 12:15

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:

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.

msg85813 - (view)

Author: Robert Collins (rbcollins) * (Python committer)

Date: 2009-04-09 12:23

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 :).

msg85815 - (view)

Author: Michael Foord (michael.foord) * (Python committer)

Date: 2009-04-09 13:15

startTestRun and stopTestRun sound good to me.

msg85823 - (view)

Author: Doug Philips (dgou)

Date: 2009-04-09 18:53

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

msg85841 - (view)

Author: Robert Collins (rbcollins) * (Python committer)

Date: 2009-04-11 08:29

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

msg86005 - (view)

Author: Barry A. Warsaw (barry) * (Python committer)

Date: 2009-04-15 23:19

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

msg86007 - (view)

Author: Robert Collins (rbcollins) * (Python committer)

Date: 2009-04-15 23:43

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

msg86011 - (view)

Author: Barry A. Warsaw (barry) * (Python committer)

Date: 2009-04-16 00:28

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

msg86052 - (view)

Author: Robert Collins (rbcollins) * (Python committer)

Date: 2009-04-17 00:16

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

msg86987 - (view)

Author: Michael Foord (michael.foord) * (Python committer)

Date: 2009-05-02 22:44

Committed in revision 72225.

History

Date

User

Action

Args

2022-04-11 14:56:47

admin

set

github: 49978

2009-05-02 22:44:44

michael.foord

set

status: open -> closed

messages: +

2009-04-17 00:16:13

rbcollins

set

files: + start-stop-TestRun.patch

messages: +

2009-04-16 00:28:22

barry

set

messages: +

2009-04-15 23:43:12

rbcollins

set

messages: +

2009-04-15 23:19:46

barry

set

nosy: + barry
messages: +

2009-04-11 08:29:35

rbcollins

set

files: + start-stop-TestRun.patch
keywords: + patch
messages: +

2009-04-09 18:53:01

dgou

set

nosy: + dgou
messages: +

2009-04-09 13:15:55

michael.foord

set

messages: +

2009-04-09 12:23:12

rbcollins

set

messages: +

2009-04-09 12:15:23

rbcollins

create