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

Method test_w_dest_close_fails

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

Source from the content-addressed store, hash-verified

3052
3053 @unittest.skipIf(MACOS, "skipped on macOS")
3054 def test_w_dest_close_fails(self):
3055 srcfile = self.Faux()
3056 destfile = self.Faux(True)
3057
3058 def _open(filename, mode='r'):
3059 if filename == 'srcfile':
3060 return srcfile
3061 if filename == 'destfile':
3062 return destfile
3063 assert 0 # shouldn't reach here.
3064
3065 with support.swap_attr(shutil, 'open', _open):
3066 shutil.copyfile('srcfile', 'destfile')
3067 self.assertTrue(srcfile._entered)
3068 self.assertTrue(destfile._entered)
3069 self.assertTrue(destfile._raised)
3070 self.assertTrue(srcfile._exited_with[0] is OSError)
3071 self.assertEqual(srcfile._exited_with[1].args,
3072 ('Cannot close',))
3073
3074 @unittest.skipIf(MACOS, "skipped on macOS")
3075 def test_w_source_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