You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unittest.mock.seal doesn't work as expected with AsyncMock #100287
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 the if self._mock_sealed: check.
Activity
pythongh-100287: Fix unittest.mock.seal with AsyncMock
gh-100287: Fix unittest.mock.seal with AsyncMock (#100496)
[3.11] pythongh-100287: Fix unittest.mock.seal with AsyncMock (python…
[3.10] pythongh-100287: Fix unittest.mock.seal with AsyncMock (python…
[3.11] gh-100287: Fix unittest.mock.seal with AsyncMock (GH-100496) (#…
[3.10] gh-100287: Fix unittest.mock.seal with AsyncMock (GH-100496) (#…
Merged main into regmachine branch (#50)