mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
ea576933b9
Since Python 3.6, subprocess supports decoding stdout and stderr. Like before, decoding errors are handled using "backslashreplace". One difference: In the event of a decoding error, pip previously logged a warning before trying again with "backslashreplace". Subprocess does not log such a warning.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import os
|
|
|
|
import pytest
|
|
|
|
from pip._internal.utils.compat import get_path_uid
|
|
|
|
|
|
def test_get_path_uid():
|
|
path = os.getcwd()
|
|
assert get_path_uid(path) == os.stat(path).st_uid
|
|
|
|
|
|
@pytest.mark.skipif("not hasattr(os, 'O_NOFOLLOW')")
|
|
def test_get_path_uid_without_NOFOLLOW(monkeypatch):
|
|
monkeypatch.delattr("os.O_NOFOLLOW")
|
|
path = os.getcwd()
|
|
assert get_path_uid(path) == os.stat(path).st_uid
|
|
|
|
|
|
# Skip unconditionally on Windows, as symlinks need admin privs there
|
|
@pytest.mark.skipif("sys.platform == 'win32'")
|
|
@pytest.mark.skipif("not hasattr(os, 'symlink')")
|
|
def test_get_path_uid_symlink(tmpdir):
|
|
f = tmpdir / "symlink" / "somefile"
|
|
f.parent.mkdir()
|
|
f.write_text("content")
|
|
fs = f + '_link'
|
|
os.symlink(f, fs)
|
|
with pytest.raises(OSError):
|
|
get_path_uid(fs)
|
|
|
|
|
|
@pytest.mark.skipif("not hasattr(os, 'O_NOFOLLOW')")
|
|
@pytest.mark.skipif("not hasattr(os, 'symlink')")
|
|
def test_get_path_uid_symlink_without_NOFOLLOW(tmpdir, monkeypatch):
|
|
monkeypatch.delattr("os.O_NOFOLLOW")
|
|
f = tmpdir / "symlink" / "somefile"
|
|
f.parent.mkdir()
|
|
f.write_text("content")
|
|
fs = f + '_link'
|
|
os.symlink(f, fs)
|
|
with pytest.raises(OSError):
|
|
get_path_uid(fs)
|