This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients Arfrever, Julian, Yaroslav.Halchenko, abingham, bfroehle, borja.ruiz, brett.cannon, chris.jerdonek, eric.araujo, eric.snow, exarkun, ezio.melotti, flox, fperez, hpk, michael.foord, nchauvat, ncoghlan, pitrou, r.david.murray, santoso.wijaya, serhiy.storchaka, spiv
Date 2013-02-11.20:04:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360613097.87.0.687106328187.issue16997@psf.upfronthosting.co.za>
In-reply-to
Content
>> what if there are 500 subtests in a loop and you don't want 500 failures to be
>> registered for that test case?
>
> Parametered tests have the same issue. In this case you simply don't use subtests
> or test cases.

Right, but then you lose out on both of the benefits documented for subtests:

+Without using a subtest, execution would stop after the first failure,
+and the error would be less easy to diagnose because the value of ``i``
+wouldn't be displayed::

Why tie these together?  I'm suggesting that we expose a way to benefit from the "easy to diagnose" portion without the "suspend stoppage" portion.  (The way we do this doesn't have to be one of the ways I'm suggesting, though I've suggested a few.)

>> addMessage was just one suggestion.
>
> It is quite orthogonal, actually, and could be added independently. Also, it is not clear how you would limit the addMessage to a subtest, rather than the whole test case.

It's not orthogonal because the way I suggested it, subTest() would be the composition of addMessage() and continueTest() context managers.  (addMessage limits itself by being a context manager just like subTest.)  So if we added addMessage() later, we would want to refactor subTest() to be using it.  The equivalence would be something like the following:

    with self.subTest(msg=msg, i=i):
        self.assertEqual(i % 2, 0)

    with self.continueTest():
        with self.addMessage(msg, i=i):
            self.assertEqual(i % 2, 0)

However, since it looks like we're going with changing the test case ID instead of putting the extra data only in the exception message (TestCase.longMessage) like I was suggesting before, I think adding a failFast=True or maxFailures=n parameter to subTest() has higher importance, e.g.

    with self.subTest(msg=msg, maxFailures=1, i=i):
        self.assertEqual(i % 2, 0)
History
Date User Action Args
2013-02-11 20:04:57chris.jerdoneksetrecipients: + chris.jerdonek, brett.cannon, spiv, exarkun, ncoghlan, pitrou, ezio.melotti, eric.araujo, Arfrever, r.david.murray, michael.foord, hpk, flox, fperez, Yaroslav.Halchenko, santoso.wijaya, nchauvat, Julian, abingham, eric.snow, serhiy.storchaka, borja.ruiz, bfroehle
2013-02-11 20:04:57chris.jerdoneksetmessageid: <1360613097.87.0.687106328187.issue16997@psf.upfronthosting.co.za>
2013-02-11 20:04:57chris.jerdoneklinkissue16997 messages
2013-02-11 20:04:57chris.jerdonekcreate