Lines Matching refs:path
114 # longer path if longer paths support is enabled. Internally, the os
120 # On Windows, the test can stop when trying to create a path longer
124 # On VxWorks, PATH_MAX is defined as 1024 bytes. Creating a path
133 with os_helper.change_cwd(tmpdir) as path:
134 expected = path
140 need = min_len - (len(cwd) + len(os.path.sep))
146 path = os.path.join(path, dirname)
148 os.mkdir(path)
151 os.chdir(path)
163 expected = path
177 if os.path.lexists(os_helper.TESTFN):
215 path = os_helper.TESTFN
216 old = sys.getrefcount(path)
217 self.assertRaises(TypeError, os.rename, path, 0)
218 new = sys.getrefcount(path)
308 f = os.open(path=__file__, flags=os.O_RDONLY, mode=0o777,
729 fname = os.path.join(os.environ['TEMP'], self.fname)
748 fname = "//./" + os.path.splitdrive(os.getcwd())[0]
756 self.fname = os.path.join(self.dirname, "f1")
858 dirname, name = os.path.split(filename)
904 def get_file_system(self, path):
906 root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
1000 @unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
1011 @unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
1184 if not (unix_shell and os.path.exists(unix_shell)):
1287 join = os.path.join
1329 for path in tmp1_path, tmp2_path, tmp3_path, tmp4_path, tmp5_path:
1330 with open(path, "x", encoding='utf-8') as f:
1331 f.write("I'm " + path + " and proud of it. Blame test_os.\n")
1334 os.symlink(os.path.abspath(t2_path), self.link_path)
1438 path1 = os.path.join(root, dir1)
1439 path1new = os.path.join(root, dir1 + '.new')
1448 self.assertIn(os.path.join(root, dir2), roots)
1454 base = os.path.join(os_helper.TESTFN, 'deep')
1455 p = os.path.join(base, *(['d']*depth))
1463 p = os.path.dirname(p)
1471 p = os.path.join(p, 'd')
1581 path = os.path.join(base, 'dir1', 'dir2', 'dir3')
1582 os.makedirs(path) # Should work
1583 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
1584 os.makedirs(path)
1588 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
1589 os.makedirs(path)
1590 path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
1592 os.makedirs(path)
1601 parent = os.path.join(base, 'dir1')
1602 path = os.path.join(parent, 'dir2')
1603 os.makedirs(path, 0o555)
1604 self.assertTrue(os.path.exists(path))
1605 self.assertTrue(os.path.isdir(path))
1607 self.assertEqual(os.stat(path).st_mode & 0o777, 0o555)
1615 path = os.path.join(os_helper.TESTFN, 'dir1')
1618 os.makedirs(path, mode)
1619 self.assertRaises(OSError, os.makedirs, path, mode)
1620 self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False)
1621 os.makedirs(path, 0o776, exist_ok=True)
1622 os.makedirs(path, mode=mode, exist_ok=True)
1626 os.makedirs(os.path.abspath('/'), exist_ok=True)
1633 path = os.path.join(os_helper.TESTFN, 'dir1')
1648 os.makedirs(path, mode | S_ISGID)
1651 os.makedirs(path, mode, exist_ok=True)
1653 os.chmod(path, stat.S_IMODE(os.lstat(path).st_mode) & ~S_ISGID)
1655 os.makedirs(path, mode | S_ISGID, exist_ok=True)
1661 path = os.path.join(os_helper.TESTFN, 'dir1')
1662 with open(path, 'w', encoding='utf-8') as f:
1664 self.assertRaises(OSError, os.makedirs, path)
1665 self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
1666 self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
1667 os.remove(path)
1672 path = os.path.abspath(os.path.join(os_helper.TESTFN, 'dir'))
1673 os.mkdir(path, mode=0o700)
1674 out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
1675 os.rmdir(path)
1678 f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
1682 path = os.path.join(os_helper.TESTFN, 'dir1', 'dir2', 'dir3',
1687 while not os.path.exists(path) and path != os_helper.TESTFN:
1688 path = os.path.dirname(path)
1690 os.removedirs(path)
1761 dira = os.path.join(os_helper.TESTFN, 'dira')
1763 dirb = os.path.join(dira, 'dirb')
1766 self.assertFalse(os.path.exists(dirb))
1767 self.assertFalse(os.path.exists(dira))
1768 self.assertFalse(os.path.exists(os_helper.TESTFN))
1771 dira = os.path.join(os_helper.TESTFN, 'dira')
1773 dirb = os.path.join(dira, 'dirb')
1775 create_file(os.path.join(dira, 'file.txt'))
1777 self.assertFalse(os.path.exists(dirb))
1778 self.assertTrue(os.path.exists(dira))
1779 self.assertTrue(os.path.exists(os_helper.TESTFN))
1782 dira = os.path.join(os_helper.TESTFN, 'dira')
1784 dirb = os.path.join(dira, 'dirb')
1786 create_file(os.path.join(dirb, 'file.txt'))
1789 self.assertTrue(os.path.exists(dirb))
1790 self.assertTrue(os.path.exists(dira))
1791 self.assertTrue(os.path.exists(os_helper.TESTFN))
2025 fullpath = os.path.join(os.fsencode(program_path), program)
2031 fullpath = os.path.join(program_path, program)
2038 # test os._execvpe() with an absolute path
2045 # test os._execvpe() with a relative path:
2054 # test os._execvpe() with a relative path:
2274 self.file2 = os.path.join(os_helper.TESTFN + "2")
2278 if os.path.exists(file):
2289 self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
2409 os_helper.create_empty_file(os.path.join(self.bdir, fn))
2435 f = open(os.path.join(self.dir, fn), 'rb')
2444 fullname = os.path.join(self.dir, fn)
2449 os.stat(os.path.join(self.dir, fn))
2522 os.path.join(os.path.dirname(__file__),
2578 dir_path = os.path.join(os_helper.TESTFN, dir_name)
2580 file_path = os.path.join(os_helper.TESTFN, file_name)
2591 """Test when the path is not an "extended" path."""
2600 [os.fsencode(path) for path in self.created_paths])
2603 """Test when the path starts with '\\\\?\\'."""
2606 path = '\\\\?\\' + os.path.abspath(os_helper.TESTFN)
2608 sorted(os.listdir(path)),
2612 path = b'\\\\?\\' + os.fsencode(os.path.abspath(os_helper.TESTFN))
2614 sorted(os.listdir(path)),
2615 [os.fsencode(path) for path in self.created_paths])
2621 filelink_target = os.path.abspath(__file__)
2626 left = os.path.normcase(left)
2627 right = os.path.normcase(right)
2640 self.assertTrue(os.path.exists(self.filelink_target))
2641 self.assertTrue(os.path.exists(self.filelinkb_target))
2642 self.assertFalse(os.path.exists(self.filelink))
2643 self.assertFalse(os.path.exists(self.filelinkb))
2666 path = os.readlink(FakePath(self.filelinkb))
2667 self.assertPathEqual(path, self.filelinkb_target)
2668 self.assertIsInstance(path, bytes)
2674 path = os.readlink(self.filelinkb)
2675 self.assertPathEqual(path, self.filelinkb_target)
2676 self.assertIsInstance(path, bytes)
2683 filelink_target = os.path.abspath(__file__)
2685 dirlink_target = os.path.dirname(filelink_target)
2689 assert os.path.exists(self.dirlink_target)
2690 assert os.path.exists(self.filelink_target)
2691 assert not os.path.exists(self.dirlink)
2692 assert not os.path.exists(self.filelink)
2693 assert not os.path.exists(self.missing_link)
2696 if os.path.exists(self.filelink):
2698 if os.path.exists(self.dirlink):
2700 if os.path.lexists(self.missing_link):
2705 self.assertTrue(os.path.exists(self.dirlink))
2706 self.assertTrue(os.path.isdir(self.dirlink))
2707 self.assertTrue(os.path.islink(self.dirlink))
2712 self.assertTrue(os.path.exists(self.filelink))
2713 self.assertTrue(os.path.isfile(self.filelink))
2714 self.assertTrue(os.path.islink(self.filelink))
2720 if os.path.lexists(linkname):
2723 assert not os.path.exists(target)
2736 self.assertFalse(os.path.isdir(self.missing_link))
2751 level1 = os.path.abspath(os_helper.TESTFN)
2752 level2 = os.path.join(level1, "level2")
2753 level3 = os.path.join(level2, "level3")
2760 file1 = os.path.abspath(os.path.join(level1, "file1"))
2766 link = os.path.join(level2, "link")
2767 os.symlink(os.path.relpath(file1), "link")
2776 os.stat(os.path.relpath(link)))
2781 os.stat(os.path.relpath(link)))
2785 @unittest.skipUnless(os.path.lexists(r'C:\Users\All Users')
2786 and os.path.exists(r'C:\ProgramData'),
2792 # stores the "PrintName" DOS path (e.g. "C:\") first,
2794 # NT path (e.g. "\??\C:\"). The "All Users" link, on
2798 self.assertTrue(os.path.samefile(target, r'C:\ProgramData'))
2805 path = os.path.join(*[segment] * 10)
2808 ('\\' + path, segment),
2810 (segment, path),
2812 (path[:180], path[:180]),
2824 # Also test with bytes, since that is a separate code path.
2836 root = os.path.expandvars(r'%LOCALAPPDATA%\Microsoft\WindowsApps')
2837 if not os.path.isdir(root):
2840 aliases = [os.path.join(root, a)
2859 junction_target = os.path.dirname(os.path.abspath(__file__))
2862 assert os.path.exists(self.junction_target)
2863 assert not os.path.lexists(self.junction)
2866 if os.path.lexists(self.junction):
2871 self.assertTrue(os.path.lexists(self.junction))
2872 self.assertTrue(os.path.exists(self.junction))
2873 self.assertTrue(os.path.isdir(self.junction))
2878 self.assertFalse(os.path.islink(self.junction))
2879 self.assertEqual(os.path.normcase("\\\\?\\" + self.junction_target),
2880 os.path.normcase(os.readlink(self.junction)))
2884 self.assertTrue(os.path.exists(self.junction))
2885 self.assertTrue(os.path.lexists(self.junction))
2888 self.assertFalse(os.path.exists(self.junction))
2913 # The first two test the error path, __file__ tests the success path
3010 src = os.path.join('base', 'some_link')
3012 assert os.path.isdir(src)
3649 def getxattr(path, *args):
3650 with open(path, "rb") as fp:
3652 def setxattr(path, *args):
3653 with open(path, "wb", 0) as fp:
3655 def removexattr(path, *args):
3656 with open(path, "wb", 0) as fp:
3658 def listxattr(path, *args):
3659 with open(path, "rb") as fp:
4073 for path in (str_filename, bytes_filename, str_fspath,
4075 if path is None:
4077 with self.subTest(name=name, path=path):
4078 result = fn(path, *extra_args)
4131 self.path = os.path.realpath(os_helper.TESTFN)
4132 self.addCleanup(os_helper.rmtree, self.path)
4133 os.mkdir(self.path)
4139 filename = create_file(os.path.join(self.path, "file.txt"), b'python')
4140 entry = [entry for entry in os.scandir(self.path)].pop()
4151 self.path = os.path.realpath(os_helper.TESTFN)
4152 self.bytes_path = os.fsencode(self.path)
4153 self.addCleanup(os_helper.rmtree, self.path)
4154 os.mkdir(self.path)
4157 path = self.bytes_path if isinstance(name, bytes) else self.path
4158 filename = os.path.join(path, name)
4164 for entry in os.scandir(self.path))
4182 scandir_iter = os.scandir(self.path)
4188 scandir_iter = os.scandir(self.path)
4196 self.assertEqual(entry.path, os.path.join(self.path, name))
4198 os.stat(entry.path, follow_symlinks=False).st_ino)
4200 entry_stat = os.stat(entry.path)
4206 os.path.islink(entry.path))
4208 entry_lstat = os.stat(entry.path, follow_symlinks=False)
4225 dirname = os.path.join(self.path, "dir")
4230 os.link(filename, os.path.join(self.path, "link_file.txt"))
4234 os.symlink(dirname, os.path.join(self.path, "symlink_dir"),
4236 os.symlink(filename, os.path.join(self.path, "symlink_file.txt"))
4263 path = self.bytes_path if isinstance(name, bytes) else self.path
4264 entries = list(os.scandir(path))
4273 return self.get_entry(os.path.basename(filename))
4279 os.chdir(self.path)
4285 [os.path.basename(filename)])
4295 self.assertEqual(os.fspath(entry), os.path.join(self.path, 'file.txt'))
4303 os.path.join(os.fsencode(self.path),bytes_filename))
4306 path = os.path.join(self.path, 'dir')
4308 os.mkdir(path)
4310 os.rmdir(path)
4329 os.unlink(entry.path)
4352 os.path.join(self.path, "symlink.txt"))
4370 path_bytes = os.fsencode(self.path)
4376 self.assertEqual(entry.path,
4377 os.fsencode(os.path.join(self.path, 'file.txt')))
4383 path_bytes = cls(os.fsencode(self.path))
4390 self.assertEqual(entry.path,
4391 os.fsencode(os.path.join(self.path, 'file.txt')))
4393 self.assertIs(type(entry.path), bytes)
4402 os.symlink('file.txt', os.path.join(self.path, 'link'))
4405 with os_helper.open_dir_fd(self.path) as fd:
4412 self.assertEqual(entry.path, entry.name)
4427 iterator = os.scandir(self.path)
4443 iterator = os.scandir(self.path)
4454 with os.scandir(self.path) as iterator:
4462 with os.scandir(self.path) as iterator:
4470 with os.scandir(self.path) as iterator:
4479 iterator = os.scandir(self.path)
4485 iterator = os.scandir(self.path)
4498 for b in b'hello', b'goodbye', b'some/path/and/file':
4502 for s in 'hello', 'goodbye', 'some/path/and/file':
4506 for p in "path/like/object", b"path/like/object":
4510 self.assertEqual(b"path/like/object", os.fsencode(pathlike))
4511 self.assertEqual("path/like/object", os.fsdecode(pathlike))