mirror of https://github.com/pypa/pip
Fix various typing errors on Windows
This commit is contained in:
parent
e0c7f24ee4
commit
7d27b9c412
|
@ -266,14 +266,14 @@ class TestPipResult:
|
|||
if sys.platform == "win32":
|
||||
|
||||
@property
|
||||
def stdout(self):
|
||||
def stdout(self) -> str:
|
||||
return self._impl.stdout.replace("\r\n", "\n")
|
||||
|
||||
@property
|
||||
def stderr(self):
|
||||
def stderr(self) -> str:
|
||||
return self._impl.stderr.replace("\r\n", "\n")
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return str(self._impl).replace("\r\n", "\n")
|
||||
|
||||
else:
|
||||
|
@ -618,7 +618,7 @@ class PipTestEnvironment(TestFileEnvironment):
|
|||
cwd = cwd or self.cwd
|
||||
if sys.platform == "win32":
|
||||
# Partial fix for ScriptTest.run using `shell=True` on Windows.
|
||||
args = [str(a).replace("^", "^^").replace("&", "^&") for a in args]
|
||||
args = tuple(str(a).replace("^", "^^").replace("&", "^&") for a in args)
|
||||
|
||||
if allow_error:
|
||||
kw["expect_error"] = True
|
||||
|
|
|
@ -14,7 +14,7 @@ from werkzeug.serving import make_server as _make_server
|
|||
from .compat import nullcontext
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
Body = Iterable[bytes]
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MockServer(BaseWSGIServer):
|
|||
mock: Mock = Mock()
|
||||
|
||||
|
||||
# Applies on Python 2 and Windows.
|
||||
# Applies on Windows.
|
||||
if not hasattr(signal, "pthread_sigmask"):
|
||||
# We're not relying on this behavior anywhere currently, it's just best
|
||||
# practice.
|
||||
|
@ -41,11 +41,17 @@ else:
|
|||
except AttributeError:
|
||||
mask = set(range(1, signal.NSIG))
|
||||
|
||||
old_mask = signal.pthread_sigmask(signal.SIG_SETMASK, mask)
|
||||
old_mask = signal.pthread_sigmask( # type: ignore[attr-defined]
|
||||
signal.SIG_SETMASK, # type: ignore[attr-defined]
|
||||
mask,
|
||||
)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
signal.pthread_sigmask(signal.SIG_SETMASK, old_mask)
|
||||
signal.pthread_sigmask( # type: ignore[attr-defined]
|
||||
signal.SIG_SETMASK, # type: ignore[attr-defined]
|
||||
old_mask,
|
||||
)
|
||||
|
||||
|
||||
class _RequestHandler(WSGIRequestHandler):
|
||||
|
|
|
@ -65,7 +65,11 @@ class TestUserCacheDir:
|
|||
def my_get_win_folder(csidl_name: str) -> str:
|
||||
return "\u00DF\u00E4\u03B1\u20AC"
|
||||
|
||||
monkeypatch.setattr(platformdirs.windows, "get_win_folder", my_get_win_folder)
|
||||
monkeypatch.setattr(
|
||||
platformdirs.windows, # type: ignore[attr-defined]
|
||||
"get_win_folder",
|
||||
my_get_win_folder,
|
||||
)
|
||||
|
||||
# Do not use the isinstance expression directly in the
|
||||
# assert statement, as the Unicode characters in the result
|
||||
|
|
|
@ -51,10 +51,9 @@ class TestLocations:
|
|||
# now patch
|
||||
tempfile.gettempdir = lambda: self.tempdir
|
||||
getpass.getuser = lambda: self.username
|
||||
os.geteuid = lambda: self.st_uid
|
||||
os.fstat = lambda fd: self.get_mock_fstat(fd)
|
||||
|
||||
if sys.platform != "win32":
|
||||
os.geteuid = lambda: self.st_uid
|
||||
pwd.getpwuid = self.get_mock_getpwuid
|
||||
|
||||
def revert_patch(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue