Lines Matching refs:src

142         with open(srcname, "rb") as src:
145 infd = src.fileno()
445 src = os.path.join(TESTFN, 'cheese')
447 os.mkdir(src)
448 os.symlink(src, dst)
458 src = os.path.join(TESTFN, 'cheese')
460 os.mkdir(src)
461 open(os.path.join(src, 'spam'), 'wb').close()
462 _winapi.CreateJunction(src, dst)
518 src_dir = os.path.join(tmp_dir, 'src')
587 def _filter(src, names):
590 path = os.path.join(src, name)
626 def _ignore(src, names):
627 invokations.append(src)
628 self.assertIsInstance(src, str)
701 self.assertEqual(a, os.path.join(src, 'foo'))
705 src = self.mkdtemp()
707 with open(os.path.join(src, 'foo'), 'w', encoding='utf-8') as f:
709 shutil.copytree(src, dst, copy_function=custom_cpfun)
732 src, dst, error_msg = errors[0]
748 def _copy(src, dst):
749 copied.append((src, dst))
806 src = os.path.join(src_dir, 'foo')
807 write_file(src, 'foo')
812 # copytree where dst is a subdirectory of src, see Issue 38688
818 src = os.path.join(src_dir, 'pol')
819 write_file(src, 'pol')
830 src = os.path.join(tmp_dir, 'foo')
834 write_file(src, 'foo')
836 os.symlink(src, src_link)
838 os.chmod(src, stat.S_IRWXU|stat.S_IRWXG)
841 self.assertNotEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
842 shutil.copymode(src, dst)
843 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
846 # follow src link
849 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
852 shutil.copymode(src, dst_link)
853 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
857 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
863 src = os.path.join(tmp_dir, 'foo')
867 write_file(src, 'foo')
869 os.symlink(src, src_link)
871 os.chmod(src, stat.S_IRWXU|stat.S_IRWXG)
879 self.assertNotEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
880 # src link - use chmod
883 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
886 shutil.copymode(src, dst_link, follow_symlinks=False)
887 self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
893 src = os.path.join(tmp_dir, 'foo')
897 write_file(src, 'foo')
899 os.symlink(src, src_link)
908 src = os.path.join(tmp_dir, 'foo')
912 write_file(src, 'foo')
913 src_stat = os.stat(src)
914 os.utime(src, (src_stat.st_atime,
917 self.assertNotEqual(os.stat(src).st_mtime, os.stat(dst).st_mtime)
918 os.symlink(src, src_link)
943 self.assertTrue(abs(os.stat(src).st_mtime - os.stat(dst).st_mtime) <
980 src = os.path.join(tmp_dir, 'foo')
981 write_file(src, 'foo')
986 shutil._copyxattr(src, dst)
988 os.setxattr(src, 'user.foo', b'42')
989 os.setxattr(src, 'user.bar', b'43')
990 shutil._copyxattr(src, dst)
991 self.assertEqual(sorted(os.listxattr(src)), sorted(os.listxattr(dst)))
993 os.getxattr(src, 'user.foo'),
1008 shutil._copyxattr(src, dst)
1014 if fname == src:
1020 shutil._copyxattr(src, dst)
1025 src = os.path.join(tmp_dir, 'the_original')
1027 write_file(src, src)
1029 os.setxattr(src, 'user.the_value', b'fiddly')
1036 shutil.copystat(src, dst)
1049 src = os.path.join(tmp_dir, 'foo')
1051 write_file(src, 'foo')
1052 os.symlink(src, src_link)
1053 os.setxattr(src, 'trusted.foo', b'42')
1086 src = os.path.join(tmp_dir, 'foo')
1089 write_file(src, 'foo')
1090 os.symlink(src, src_link)
1096 self.assertEqual(read_file(src), read_file(dst))
1128 src = os.path.join(tmp_dir, 'foo')
1131 write_file(src, 'foo')
1132 os.symlink(src, src_link)
1137 src_stat = os.stat(src)
1142 self.assertEqual(read_file(src), read_file(dst))
1163 src = os.path.join(tmp_dir, 'foo')
1165 write_file(src, 'foo')
1166 os.setxattr(src, 'user.foo', b'42')
1167 shutil.copy2(src, dst)
1169 os.getxattr(src, 'user.foo'),
1178 src = os.path.join(src_dir, 'foo')
1179 write_file(src, 'foo')
1180 rv = fn(src, dst_dir)
1182 rv = fn(src, os.path.join(dst_dir, 'bar'))
1203 # raise *err* because of src rather than FileNotFoundError because of dst
1212 src = os.path.join(tmp_dir, 'src')
1216 write_file(src, 'foo')
1217 os.symlink(src, link)
1230 src = os.path.join(TESTFN, 'cheese')
1233 with open(src, 'w', encoding='utf-8') as f:
1236 os.link(src, dst)
1239 self.assertRaises(shutil.SameFileError, shutil.copyfile, src, dst)
1240 with open(src, 'r', encoding='utf-8') as f:
1250 src = os.path.join(TESTFN, 'cheese')
1253 with open(src, 'w', encoding='utf-8') as f:
1255 # Using `src` here would mean we end up with a symlink pointing
1259 self.assertRaises(shutil.SameFileError, shutil.copyfile, src, dst)
1260 with open(src, 'r', encoding='utf-8') as f:
1321 # test copy() and copyfile() raising proper exceptions when src and/or
2007 def _check_move_file(self, src, dst, real_dst):
2008 with open(src, "rb") as f:
2010 shutil.move(src, dst)
2013 self.assertFalse(os.path.exists(src))
2015 def _check_move_dir(self, src, dst, real_dst):
2016 contents = sorted(os.listdir(src))
2017 shutil.move(src, dst)
2019 self.assertFalse(os.path.exists(src))
2031 src = pathlib.Path(self.src_file)
2032 self._check_move_file(src, self.dst_dir, self.dst_file)
2095 for src, dst in [('srcdir', 'srcdir/dest')]:
2096 src = os.path.join(TESTFN, src)
2098 self.assertTrue(shutil._destinsrc(src, dst),
2100 'dst (%s) is not in src (%s)' % (dst, src))
2107 for src, dst in [('srcdir', 'src/dest'), ('srcdir', 'srcdir.new')]:
2108 src = os.path.join(TESTFN, src)
2110 self.assertFalse(shutil._destinsrc(src, dst),
2112 'dst (%s) is in src (%s)' % (dst, src))
2139 src = os.path.join(self.src_dir, 'baz')
2141 os.symlink(src, dst)
2145 self.assertEqual(os.path.realpath(src), os.path.realpath(dst_link))
2150 src = os.path.join(self.src_dir, 'baz')
2152 os.mkdir(src)
2153 os.symlink(src, dst)
2157 self.assertTrue(os.path.samefile(src, dst_link))
2171 def _copy(src, dst):
2172 moved.append((src, dst))
2179 def _copy(src, dst):
2180 moved.append((src, dst))
2347 with open(TESTFN, "rb") as src:
2349 yield (src, dst)
2351 def assert_files_eq(self, src, dst):
2352 with open(src, 'rb') as fsrc:
2357 with self.get_files() as (src, dst):
2358 shutil.copyfileobj(src, dst)
2362 with self.get_files() as (src, dst):
2363 shutil.copyfileobj(src, dst)
2364 assert not src.closed
2368 with self.get_files() as (src, dst):
2369 shutil.copyfileobj(src, dst)
2370 self.assertEqual(src.tell(), self.FILESIZE)
2426 with open(TESTFN, "rb") as src:
2428 yield (src, dst)
2442 with self.get_files() as (src, dst):
2443 self.zerocopy_fun(src, dst)
2446 with self.get_files() as (src, dst):
2453 with self.get_files() as (src, dst):
2455 self.zerocopy_fun(src, src)
2456 # Make sure src file is not corrupted.
2466 srcname = TESTFN + 'src'
2473 with open(srcname, "rb") as src:
2475 self.zerocopy_fun(src, dst)
2491 with self.get_files() as (src, dst):
2493 self.zerocopy_fun(src, dst)
2500 with self.get_files() as (src, dst):
2501 self.assertRaises(OSError, self.zerocopy_fun, src, dst)
2512 with io.BytesIO(self.FILEDATA) as src:
2515 self.zerocopy_fun(src, dst)
2516 shutil.copyfileobj(src, dst)
2521 with open(TESTFN, "rb") as src:
2524 self.zerocopy_fun(src, dst)
2525 shutil.copyfileobj(src, dst)
2541 with self.get_files() as (src, dst):
2543 shutil._fastcopy_sendfile(src, dst)
2548 # Emulate a case where src file size cannot be determined.
2552 with self.get_files() as (src, dst):
2553 shutil._fastcopy_sendfile(src, dst)
2560 # multiple times, also in order to emulate a src fd which gets
2565 with self.get_files() as (src, dst):
2566 shutil._fastcopy_sendfile(src, dst)
2578 with self.get_files() as (src, dst):
2579 shutil._fastcopy_sendfile(src, dst)
2610 with self.get_files() as (src, dst):
2612 shutil._fastcopy_sendfile(src, dst)
2627 def zerocopy_fun(self, src, dst):
2628 return shutil._fastcopy_fcopyfile(src, dst, posix._COPYFILE_DATA)