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

isfile (Python says no, pyfakefs says yes) #374

Closed
agroce opened this issue Apr 9, 2018 · 4 comments
Closed

isfile (Python says no, pyfakefs says yes) #374

agroce opened this issue Apr 9, 2018 · 4 comments
Labels

Comments

@agroce
Copy link

agroce commented Apr 9, 2018

import shutil
import pyfakefs.fake_filesystem
import os

ROOT_PATH = "/Volumes/ramdisk/newtest"

fs = pyfakefs.fake_filesystem.FakeFilesystem()
fs.CreateDirectory('/Volumes')
fs.CreateDirectory('/Volumes/ramdisk')
fs.CreateDirectory('/Volumes/ramdisk/newtest')
os0 = pyfakefs.fake_filesystem.FakeOsModule(fs)
opener0 = pyfakefs.fake_filesystem.FakeFileOpen(fs)

if True:
    os0 = os
    shutil.rmtree(ROOT_PATH)
    os.mkdir(ROOT_PATH)
    opener0 = open

component0 = "alpha" 
path0 = ROOT_PATH 
path0 += os.path.sep + component0 
component0 = "" 
file0 = opener0(path0,'w') 
path0 += os.path.sep + component0 
result = os0.path.isfile(path0)
print result
@mrbean-bremen
Copy link
Member

mrbean-bremen commented Apr 10, 2018

For reference: returns False under Linux and Windows, True under MacOS.

@mrbean-bremen
Copy link
Member

I don't understand this stuff with file paths ending with separators - it seems quite random to me. Sometimes MacOS behavior is the opposite of Windows and Linux, sometimes it's Windows that behaves different, and I don't see a pattern here at all. </rant>
I'm giving up for now, maybe will have another go at the weekend.

@mrbean-bremen
Copy link
Member

Just to let you know - I'm just mostly working on another project, so it may be a few days before I get back to pyfakefs.

@mrbean-bremen
Copy link
Member

Fixed by #382

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