summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorAndrew Dunai <andunai@gmail.com>2018-12-04 09:08:45 (GMT)
committerChris Withers <chris@withers.org>2018-12-04 09:08:45 (GMT)
commite63e617ebbe481c498bdf037a62e09f4f9f3963f (patch)
tree1389d5b9eb62ec43ab01823a9470ecf16d122aa4 /Lib/unittest/test
parenteeb719eac6347f5b6e85389aa13a386024766806 (diff)
downloadcpython-e63e617ebbe481c498bdf037a62e09f4f9f3963f.zip
cpython-e63e617ebbe481c498bdf037a62e09f4f9f3963f.tar.gz
cpython-e63e617ebbe481c498bdf037a62e09f4f9f3963f.tar.bz2
bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of _Call/_MagicProxy. (#10873)
Fix minor typo in test function name.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/testmock/testcallable.py2
-rw-r--r--Lib/unittest/test/testmock/testmock.py16
2 files changed, 16 insertions, 2 deletions
diff --git a/Lib/unittest/test/testmock/testcallable.py b/Lib/unittest/test/testmock/testcallable.py
index af1ce7e..34474c4 100644
--- a/Lib/unittest/test/testmock/testcallable.py
+++ b/Lib/unittest/test/testmock/testcallable.py
@@ -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)
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index e46ef7b..0a638b7 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -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()