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

Method test_w_source_close_fails

Lib/test/test_shutil.py:3075–3094  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3073
3074 @unittest.skipIf(MACOS, "skipped on macOS")
3075 def test_w_source_close_fails(self):
3076
3077 srcfile = self.Faux(True)
3078 destfile = self.Faux()
3079
3080 def _open(filename, mode='r'):
3081 if filename == 'srcfile':
3082 return srcfile
3083 if filename == 'destfile':
3084 return destfile
3085 assert 0 # shouldn't reach here.
3086
3087 with support.swap_attr(shutil, 'open', _open):
3088 with self.assertRaises(OSError):
3089 shutil.copyfile('srcfile', 'destfile')
3090 self.assertTrue(srcfile._entered)
3091 self.assertTrue(destfile._entered)
3092 self.assertFalse(destfile._raised)
3093 self.assertTrue(srcfile._exited_with[0] is None)
3094 self.assertTrue(srcfile._raised)
3095
3096
3097class TestCopyFileObj(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

copyfileMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected