Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AddaddCleanup tounittest.subTest #134079

Open
Labels
stdlibPython modules in the Lib dirtype-featureA feature request or enhancement
@encukou

Description

@encukou

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp