-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
I noticed this while reviewing #100252 (comment)
I believe the following test case should pass, but it doesn't on main
import unittest
from unittest.mock import Mock, seal
class AsyncClass:
async def async_method(self): pass
def normal_method(self): pass
class Case(unittest.TestCase):
def test_spec_normal_methods_on_class_with_mock_seal(self):
mock = Mock(AsyncClass)
seal(mock)
# test passes, aka this raises AttributError
with self.assertRaises(AttributeError):
mock.normal_method
# test fails, aka this does not raise AttributError
with self.assertRaises(AttributeError):
mock.async_method
unittest.main()
It's easy to fix, just need to move the clause that handles AsyncMock after the if self._mock_sealed:
check.
cc @sobolevn who moved the if self._mock_sealed:
check earlier in https://github.com/python/cpython/pull/28300/files , but not all the way
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error