◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
10 changes: 9 additions & 1 deletion Doc/library/os.path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,19 @@ the :mod:`glob` module.)
.. function:: realpath(path)

Return the canonical path of the specified filename, eliminating any symbolic
links encountered in the path (if they are supported by the operating system).

.. versionchanged:: 3.6
Accepts a :term:`path-like object`.


.. function:: relpath(path, start=os.curdir)

Expand Down
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ characters or bytes unrepresentable at the OS level.
environment variable and does not use :envvar:`HOME`, which is not normally set
for regular user accounts.


ncurses
-------
Expand Down
198 changes: 195 additions & 3 deletions Lib/test/test_ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@
from test import support, test_genericpath
from tempfile import TemporaryFile

try:
import nt
except ImportError:
# Most tests can complete without the nt module,
# but for those that require it we import here.
nt = None

def tester(fn, wantResult):
fn = fn.replace("\\", "\\\\")
gotResult = eval(fn)
Expand Down Expand Up @@ -194,6 +203,189 @@ def test_normpath(self):
tester("ntpath.normpath('\\\\.\\NUL')", r'\\.\NUL')
tester("ntpath.normpath('\\\\?\\D:/XY\\Z')", r'\\?\D:/XY\Z')

def test_expandvars(self):
with support.EnvironmentVarGuard() as env:
env.clear()
Expand Down Expand Up @@ -288,11 +480,11 @@ def test_abspath(self):

def test_relpath(self):
tester('ntpath.relpath("a")', 'a')
tester('ntpath.relpath(os.path.abspath("a"))', 'a')
tester('ntpath.relpath("a/b")', 'a\\b')
tester('ntpath.relpath("../a/b")', '..\\a\\b')
with support.temp_cwd(support.TESTFN) as cwd_dir:
currentdir = os.path.basename(cwd_dir)
tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
tester('ntpath.relpath("a", "b/c")', '..\\..\\a')
Expand Down Expand Up @@ -417,7 +609,7 @@ def test_ismount(self):
# locations below cannot then refer to mount points
#
drive, path = ntpath.splitdrive(sys.executable)
with support.change_cwd(os.path.dirname(sys.executable)):
self.assertFalse(ntpath.ismount(drive.lower()))
self.assertFalse(ntpath.ismount(drive.upper()))

Expand Down
5 changes: 1 addition & 4 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -3358,10 +3358,7 @@ def test_oserror_filename(self):
if hasattr(os, "lchmod"):
funcs.append((self.filenames, os.lchmod, 0o777))
if hasattr(os, "readlink"):
if sys.platform == "win32":
funcs.append((self.unicode_filenames, os.readlink,))
else:
funcs.append((self.filenames, os.readlink,))


for filenames, func, *func_args in funcs:
Expand Down
Loading
Toggle all file notes Toggle all file annotations