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

Method test_unexpected_error

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

Source from the content-addressed store, hash-verified

1601 self.assertEqual(os.listdir(dir), [])
1602
1603 def test_unexpected_error(self):
1604 dir = tempfile.mkdtemp()
1605 self.addCleanup(os_helper.rmtree, dir)
1606 with mock.patch('tempfile._O_TMPFILE_WORKS', False), \
1607 mock.patch('os.unlink') as mock_unlink, \
1608 mock.patch('os.open') as mock_open, \
1609 mock.patch('os.close') as mock_close:
1610 mock_unlink.side_effect = KeyboardInterrupt()
1611 with self.assertRaises(KeyboardInterrupt):
1612 tempfile.TemporaryFile(dir=dir)
1613 mock_close.assert_called()
1614 self.assertEqual(os.listdir(dir), [])
1615
1616
1617# Helper for test_del_on_shutdown

Callers

nothing calls this directly

Calls 6

mkdtempMethod · 0.80
addCleanupMethod · 0.80
assert_calledMethod · 0.80
listdirMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected