Skip to content
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

Problem with directory by UNC path #606

Closed
hg-bauerc opened this issue Jun 2, 2021 · 3 comments
Closed

Problem with directory by UNC path #606

hg-bauerc opened this issue Jun 2, 2021 · 3 comments
Labels

Comments

@hg-bauerc
Copy link

When creating a directory by UNC path (like //host/share/dir) at least two functions on this path (or FS object) fail:

  • os.stat
  • Path.is_dir
with Patcher() as patcher:
    s = '//host/share/dir'
    patcher.fs.create_dir(s)
    Path(s).is_dir()  # is False
    os.stat(s)  # raises exception
Failure
Traceback (most recent call last):
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 2000, in get_object_from_normpath
    target_object = target_object.get_entry(component)
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 694, in get_entry
    return self.contents[to_string(pathname_name)]
KeyError: 'host'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\projects\PS\PiA\productions\tests\tasks\test_get_prodlines_from_fs.py", line 53, in test
    os.stat(s)  # raises exception
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 4051, in stat
    return self.filesystem.stat(path, follow_symlinks)
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 1187, in stat
    self.get_object(parent_dir.path)
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 2025, in get_object
    return self.get_object_from_normpath(file_path, check_read_perm)
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 2005, in get_object_from_normpath
    self.raise_os_error(errno.ENOENT, file_path)
  File "C:\projects\PS\virtualenvs\pia-TGUuFkkm-py3.8\lib\site-packages\pyfakefs\fake_filesystem.py", line 1010, in raise_os_error
    raise OSError(errno, message, filename)
FileNotFoundError: [Errno 2] No such file or directory in the fake filesystem: '\\host\\share'

Env:
Windows-10-10.0.19041-SP0
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)]
pyfakefs 4.4.0

@mrbean-bremen
Copy link
Member

Thanks for the report - looks like UNC path handling is missing in some function.

@mrbean-bremen
Copy link
Member

@hg-bauerc - should be fixed in master now, please check if it works for you.

github-actions bot pushed a commit that referenced this issue Jun 3, 2021
… fix directory path evaluation for UNC paths - fixes #606
@hg-bauerc
Copy link
Author

Yes, works for me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants