MCPcopy Index your code
hub / github.com/python/cpython / test_mock_open_write

Method test_mock_open_write

Lib/test/test_unittest/testmock/testmock.py:2080–2089  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2078 self.assertEqual('abc', next(mopen()))
2079
2080 def test_mock_open_write(self):
2081 # Test exception in file writing write()
2082 mock_namedtemp = mock.mock_open(mock.MagicMock(name='JLV'))
2083 with mock.patch('tempfile.NamedTemporaryFile', mock_namedtemp):
2084 mock_filehandle = mock_namedtemp.return_value
2085 mock_write = mock_filehandle.write
2086 mock_write.side_effect = OSError('Test 2 Error')
2087 def attempt():
2088 tempfile.NamedTemporaryFile().write('asd')
2089 self.assertRaises(OSError, attempt)
2090
2091 def test_mock_open_alter_readline(self):
2092 mopen = mock.mock_open(read_data='foo\nbarn')

Callers

nothing calls this directly

Calls 2

mock_openMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected