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

Method test_w_dest_open_fails

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

Source from the content-addressed store, hash-verified

3034
3035 @unittest.skipIf(MACOS, "skipped on macOS")
3036 def test_w_dest_open_fails(self):
3037 srcfile = self.Faux()
3038
3039 def _open(filename, mode='r'):
3040 if filename == 'srcfile':
3041 return srcfile
3042 if filename == 'destfile':
3043 raise OSError('Cannot open "destfile"')
3044 assert 0 # shouldn't reach here.
3045
3046 with support.swap_attr(shutil, 'open', _open):
3047 shutil.copyfile('srcfile', 'destfile')
3048 self.assertTrue(srcfile._entered)
3049 self.assertTrue(srcfile._exited_with[0] is OSError)
3050 self.assertEqual(srcfile._exited_with[1].args,
3051 ('Cannot open "destfile"',))
3052
3053 @unittest.skipIf(MACOS, "skipped on macOS")
3054 def test_w_dest_close_fails(self):

Callers

nothing calls this directly

Calls 3

copyfileMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected