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

All TestCase classes use a shared stack for class cleanup #99645

Closed
Labels
3.10only security fixes3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error
@serhiy-storchaka

Description

@serhiy-storchaka

TestCase class methodsaddClassCleanup() anddoClassCleanups() are similar to instance methodsaddCleanup() anddoCleanups().add*Cleanup() add a callback into a list, anddo*Cleanups() pop them from a list and call. The main difference is that the latter methods use a list stored as an instance attribute while the former use a list stored as a class attribute.

The problem is that the class attributeTestCase._class_cleanups is shared between allTestCase subclasses. It usually does not cause the problem, because tests in different test classes are run sequentially, but if you run a new test suite while running a test, and the outer test class useaddClassCleanup(), the callback registered for the outer test class will be called when cleaning up the inner test class. It can happen when you testunittest itself. It really happened, and was unnoticed only because the outer class did not useaddClassCleanup().

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp