Skip to content
Myr

revert path prefix stripping, modify test to work with prefix

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by cAtaman · committed by cAtaman · parent f40631b · Browse files · 2 files+18 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−14 removed

  • tests:+13 added−0 removed
  • other:+5 added−14 removed

2 files+18 added−14 removed

modified:src/click/types.py+5 added-14 removed
843 unmodified lines
844 # path even if the path to the link is absolute.845 if os.path.islink(rv):846 rv = os.readlink(rv)847848 # absolute links849 if os.path.isabs(rv):850 # os.readlink prepends path prefixes to absolute851 # links in windows.852 # https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces853 # Here we strip prefix from the resolved path854 rv_drive, rv_path = os.path.splitdrive(rv)855 stripped_rv_drive = rv_drive.split(os.path.sep)[-1]856 rv = os.path.join(stripped_rv_drive, rv_path)857 else:858 # For relative symlinks we join dir_ to the resolved859 # symlink. This will make it relative to the original860 # containing directory.861 rv = os.path.join(dir_, rv)848 # Join dir_ with the resolved symlink if the resolved849 # path is relative. This will make it relative to the850 # original containing directory.851 if not os.path.isabs(rv):852 rv = os.path.join(dir_, rv)853854 try:855 st = os.stat(rv)856 except OSError:
205 unmodified lines
modified:tests/test_types.py+13 added
124 unmodified lines
125126 # test127 ctx = click.Context(click.Command("do_stuff"))128 rv = click.Path(resolve_path=True).convert(sym_path, None, ctx)129130 if os.path.isabs(rv):131 # os.readlink prepends path prefixes to absolute132 # links in windows.133 # https://docs.microsoft.com/en-us/windows/win32/134 # ... fileio/naming-a-file#win32-file-namespaces135 #136 # Here we strip win32 path prefix from the resolved path137 rv_drive, rv_path = os.path.splitdrive(rv)138 stripped_rv_drive = rv_drive.split(os.path.sep)[-1]139 rv = os.path.join(stripped_rv_drive, rv_path)140141 assert pathlib.Path(rv) == pathlib.Path(real_path)142 assert rv == real_path