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

Method test_unexpected_error

Lib/test/test_tempfile.py:1179–1188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1177 self.assertEqual(os.listdir(dir), [])
1178
1179 def test_unexpected_error(self):
1180 dir = tempfile.mkdtemp()
1181 self.addCleanup(os_helper.rmtree, dir)
1182 with mock.patch('tempfile._TemporaryFileWrapper') as mock_ntf, \
1183 mock.patch('io.open', mock.mock_open()) as mock_open:
1184 mock_ntf.side_effect = KeyboardInterrupt()
1185 with self.assertRaises(KeyboardInterrupt):
1186 tempfile.NamedTemporaryFile(dir=dir)
1187 mock_open().close.assert_called()
1188 self.assertEqual(os.listdir(dir), [])
1189
1190 # How to test the mode and bufsize parameters?
1191

Callers

nothing calls this directly

Calls 8

mock_openFunction · 0.85
mkdtempMethod · 0.80
addCleanupMethod · 0.80
mock_openMethod · 0.80
assert_calledMethod · 0.80
listdirMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected