Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Feature or enhancement
Proposal:
Theunittest.subTest
context (i.e. the object you get usingwith
'sas
clause, currentlyNone
) should get methods to manage cleanups:
addCleanup
enterContext
doCleanups
And similar ones forIsolatedAsyncIOTestCase
.
They should do the same thing as the same methods onTestCase
, but with subtest scope.
Example usage:
forparamin'a','b','c':withself.subTest()assub:tempfile=make_tempfile()sub.addCleanup(os.unlink,tempfile)do_actual_test(tempfile,param)
SeeDiscuss thread for motivation/discussion.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/unittest-add-addcleanup-to-subtest/91827