mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of _Call/_MagicProxy. (#10873)
Fix minor typo in test function name.
This commit is contained in:
parent
eeb719eac6
commit
e63e617ebb
4 changed files with 34 additions and 16 deletions
|
@ -128,7 +128,7 @@ class TestCallable(unittest.TestCase):
|
|||
result.foo.assert_called_once_with(3, 2, 1)
|
||||
|
||||
|
||||
def test_create_autopsec(self):
|
||||
def test_create_autospec(self):
|
||||
mock = create_autospec(X)
|
||||
instance = mock()
|
||||
self.assertRaises(TypeError, instance)
|
||||
|
|
|
@ -9,7 +9,7 @@ from unittest import mock
|
|||
from unittest.mock import (
|
||||
call, DEFAULT, patch, sentinel,
|
||||
MagicMock, Mock, NonCallableMock,
|
||||
NonCallableMagicMock, _CallList,
|
||||
NonCallableMagicMock, _Call, _CallList,
|
||||
create_autospec
|
||||
)
|
||||
|
||||
|
@ -1665,6 +1665,20 @@ class MockTest(unittest.TestCase):
|
|||
self.assertIsInstance(mock, int)
|
||||
mock.foo
|
||||
|
||||
def test_name_attribute_of_call(self):
|
||||
# bpo-35357: _Call should not disclose any attributes whose names
|
||||
# may clash with popular ones (such as ".name")
|
||||
self.assertIsNotNone(call.name)
|
||||
self.assertEqual(type(call.name), _Call)
|
||||
self.assertEqual(type(call.name().name), _Call)
|
||||
|
||||
def test_parent_attribute_of_call(self):
|
||||
# bpo-35357: _Call should not disclose any attributes whose names
|
||||
# may clash with popular ones (such as ".parent")
|
||||
self.assertIsNotNone(call.parent)
|
||||
self.assertEqual(type(call.parent), _Call)
|
||||
self.assertEqual(type(call.parent().parent), _Call)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue