|
1 | 1 | import errno
|
| 2 | +import sys |
2 | 3 | from unittest import mock
|
3 | 4 |
|
4 | 5 | import pytest
|
@@ -120,6 +121,56 @@ def test_most_cases(
|
120 | 121 | "Consider checking your local proxy configuration"
|
121 | 122 | ' with "pip config debug".\n',
|
122 | 123 | ),
|
| 124 | + # Testing both long path error (ENOENT) |
| 125 | + # and long file/folder name error (EINVAL) on Windows |
| 126 | + pytest.param( |
| 127 | + OSError(errno.ENOENT, "No such file or directory", f"C:{'/a'*261}"), |
| 128 | + False, |
| 129 | + False, |
| 130 | + "Could not install packages due to an OSError: " |
| 131 | + f"[Errno 2] No such file or directory: 'C:{'/a'*261}'\n" |
| 132 | + "HINT: This error might have occurred since " |
| 133 | + "this system does not have Windows Long Path " |
| 134 | + "support enabled. You can find information on " |
| 135 | + "how to enable this at " |
| 136 | + "https://pip.pypa.io/warnings/enable-long-paths\n", |
| 137 | + marks=pytest.mark.skipif( |
| 138 | + sys.platform != "win32", reason="Windows-specific filename length test" |
| 139 | + ), |
| 140 | + ), |
| 141 | + pytest.param( |
| 142 | + OSError(errno.EINVAL, "No such file or directory", f"C:/{'a'*256}"), |
| 143 | + False, |
| 144 | + False, |
| 145 | + "Could not install packages due to an OSError: " |
| 146 | + f"[Errno 22] No such file or directory: 'C:/{'a'*256}'\n" |
| 147 | + "HINT: This error might be caused by a file or folder name exceeding " |
| 148 | + "255 characters, which is a Windows limitation even if long paths " |
| 149 | + "are enabled.\n", |
| 150 | + marks=pytest.mark.skipif( |
| 151 | + sys.platform != "win32", reason="Windows-specific filename length test" |
| 152 | + ), |
| 153 | + ), |
| 154 | + pytest.param( |
| 155 | + OSError( |
| 156 | + errno.EINVAL, "No such file or directory", f"C:{'/a'*261}/{'b'*256}" |
| 157 | + ), |
| 158 | + False, |
| 159 | + False, |
| 160 | + "Could not install packages due to an OSError: " |
| 161 | + f"[Errno 22] No such file or directory: 'C:{'/a' * 261}/{'b' * 256}'\n" |
| 162 | + "HINT: This error might be caused by a file or folder name exceeding " |
| 163 | + "255 characters, which is a Windows limitation even if long paths " |
| 164 | + "are enabled.\n " |
| 165 | + "HINT: This error might have occurred since " |
| 166 | + "this system does not have Windows Long Path " |
| 167 | + "support enabled. You can find information on " |
| 168 | + "how to enable this at " |
| 169 | + "https://pip.pypa.io/warnings/enable-long-paths\n", |
| 170 | + marks=pytest.mark.skipif( |
| 171 | + sys.platform != "win32", reason="Windows-specific filename length test" |
| 172 | + ), |
| 173 | + ), |
123 | 174 | ],
|
124 | 175 | )
|
125 | 176 | def test_create_os_error_message(
|
|
0 commit comments