Skip to content

Commit 42819b9

Browse files
committed
Fix os error message testcase bug on windows platforms
1 parent 3f40103 commit 42819b9

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

tests/unit/test_command_install.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import errno
2+
import sys
23
from unittest import mock
34

45
import pytest
@@ -120,18 +121,34 @@ def test_most_cases(
120121
"Consider checking your local proxy configuration"
121122
' with "pip config debug".\n',
122123
),
123-
# Testing both long path error (ENOENT) and long file/folder name error (EINVAL)
124-
(
124+
# Testing both long path error (ENOENT) and long file/folder name error (EINVAL) on Windows
125+
pytest.param(
125126
OSError(errno.ENOENT, "No such file or directory", "C:/foo/" + "a" * 261),
126127
False,
127128
False,
128-
f"""Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:/foo/{"a"*261}'\n""",
129+
"Could not install packages due to an OSError: "
130+
f"[Errno 2] No such file or directory: 'C:/foo/{'a'*261}'\n"
131+
"HINT: This error might have occurred since "
132+
"this system does not have Windows Long Path "
133+
"support enabled. You can find information on "
134+
"how to enable this at "
135+
"https://pip.pypa.io/warnings/enable-long-paths\n",
136+
marks=pytest.mark.skipif(
137+
sys.platform != "win32", reason="Windows-specific filename length test"
138+
),
129139
),
130-
(
140+
pytest.param(
131141
OSError(errno.EINVAL, "No such file or directory", "C:/foo/" + "a" * 256),
132142
False,
133143
False,
134-
f"""Could not install packages due to an OSError: [Errno 22] No such file or directory: 'C:/foo/{"a"*256}'\n""",
144+
"Could not install packages due to an OSError: "
145+
f"[Errno 22] No such file or directory: 'C:/foo/{'a'*256}'\n"
146+
"HINT: This error might be caused by a file or folder name exceeding "
147+
"255 characters, which is a Windows limitation even if long paths "
148+
"are enabled.\n",
149+
marks=pytest.mark.skipif(
150+
sys.platform != "win32", reason="Windows-specific filename length test"
151+
),
135152
),
136153
],
137154
)

0 commit comments

Comments
 (0)