aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/unittest/test/testmock/testmock.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r--Lib/unittest/test/testmock/testmock.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index fdba543b535..c99098dc4ea 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -226,6 +226,14 @@ class MockTest(unittest.TestCase):
with self.assertRaisesRegex(InvalidSpecError,
"Cannot spec attr 'B' as the spec_set "):
mock.patch.object(A, 'B', spec_set=A.B).start()
+ with self.assertRaisesRegex(InvalidSpecError,
+ "Cannot spec attr 'B' as the spec_set "):
+ mock.patch.object(A, 'B', spec_set=A.B).start()
+ with self.assertRaisesRegex(InvalidSpecError, "Cannot spec a Mock object."):
+ mock.Mock(A.B)
+ with mock.patch('builtins.open', mock.mock_open()):
+ mock.mock_open() # should still be valid with open() mocked
+
def test_reset_mock(self):
parent = Mock()