-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Short paths in Windows seem to fail to be collected #11895
Comments
Thanks for the report.
In order to narrow down on the issue, we'll probably need to bisect. I don't have windows either, but I can try with Wine. Can you provide instructions for reproducing the CI failure locally? (Doesn't have to be minimal). |
I think this should work to reproduce it. On a window machine:
diff --git a/src/xdoctest/utils/util_path.py b/src/xdoctest/utils/util_path.py
index d49b371..83a0230 100644
--- a/src/xdoctest/utils/util_path.py
+++ b/src/xdoctest/utils/util_path.py
@@ -34,19 +34,8 @@ class TempDir(object):
def ensure(self):
import tempfile
- import sys
if not self.dpath:
dpath = tempfile.mkdtemp()
- if sys.platform.startswith('win32'):
- # Force a long path
- # References:
- # https://stackoverflow.com/questions/11420689/how-to-get-long-file-system-path-from-python-on-windows
- from ctypes import create_unicode_buffer, windll
- BUFFER_SIZE = 500
- buffer = create_unicode_buffer(BUFFER_SIZE)
- get_long_path_name = windll.kernel32.GetLongPathNameW
- get_long_path_name(dpath, buffer, BUFFER_SIZE)
- dpath = buffer.value
self.dpath = dpath
return self.dpath
You can likely make this much more minimal by using |
I did not investigate into details, but I cannot reproduce the behavior using a very short path:
I'm afraid we will need more details to reproduce the issue. |
There's a misunderstanding on what I mean by "short path". It's not a path with a short length, it's a windows shorthand to refer to a real path that's longer. It's like an autocomlete. E.g.
Reference: https://superuser.com/questions/348079/how-can-i-find-the-short-path-of-a-windows-directory-file It's a silly feature, but it seems |
Ahh of course, brain fart on my part. I can reproduce the issue:
>>> from pathlib import Path
>>> p=Path(r'c:\PORTAB~1\test')
>>> p.is_dir()
True
>>> (p / "test_foo.py").is_file()
True
>>>
I will investigate this when I find some time, thanks for the report! |
I'm surprised this ever worked. Windows paths - the gift that keeps on giving :) |
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` ensures the comparsion works on Windows. Fix pytest-dev#11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` ensures the comparsion works on Windows. Fix pytest-dev#11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` as fallback ensures the comparsion works on Windows when comparing short/long paths. Fix pytest-dev#11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` as fallback ensures the comparsion works on Windows when comparing short/long paths. Fix pytest-dev#11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` as fallback ensures the comparsion works on Windows when comparing short/long paths. Fix pytest-dev#11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` as fallback ensures the comparsion works on Windows when comparing short/long paths. Fix #11895
Passing a short path in the command line was causing the matchparts check to fail, because ``Path(short_path) != Path(long_path)``. Using ``os.path.samefile`` as fallback ensures the comparsion works on Windows when comparing short/long paths. Fix pytest-dev#11895
### What kind of change does this PR introduce? * Unpins the `pytest` version now that `xdoctest` supports it. * Pins to the latest `xdoctest` supporting `pytest~=8.0`. ### Does this PR introduce a breaking change? No. ### Other information: FYI @RondeauG The newest `pytest` (v8.0.0) introduced some regressions for Windows users. An issue is already up and a patch should arrive shortly (pytest-dev/pytest#11895). Until then, use `pytest<8.0` on Windows. See also: pytest-dev/pytest#11969
This is an initial report of an issue I observed when updating xdoctest to support pytest 8.0.
What I found is that when I ran a test effectivly using the invocation:
Pytest would collect 0 tests even though there was a python file with a test in that directory.
By adding this code to convert the short path to a long path, the xdoctest failure went away, and things seem to be working now.
I've documented more of the problem here Erotemic/xdoctest#151
I don't have a MWE as I don't have a windows machine, but I'm reasonably confident that something in pytest 8 broke short path recognition on windows. I'll leave it to other devs to test further.
The text was updated successfully, but these errors were encountered: