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

unittest.mock.seal doesn't work as expected with AsyncMock #100287

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@hauntsaninja

Description

@hauntsaninja

I noticed this while reviewing#100252 (comment)

I believe the following test case should pass, but it doesn't on main

importunittestfromunittest.mockimportMock,sealclassAsyncClass:asyncdefasync_method(self):passdefnormal_method(self):passclassCase(unittest.TestCase):deftest_spec_normal_methods_on_class_with_mock_seal(self):mock=Mock(AsyncClass)seal(mock)# test passes, aka this raises AttributErrorwithself.assertRaises(AttributeError):mock.normal_method# test fails, aka this does not raise AttributErrorwithself.assertRaises(AttributeError):mock.async_methodunittest.main()

It's easy to fix, just need to move the clause that handles AsyncMock after theif self._mock_sealed: check.

cc@sobolevn who moved theif self._mock_sealed: check earlier inhttps://github.com/python/cpython/pull/28300/files , but not all the way

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp