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

getsize issue (pyfakefs returns, Python fails with OSError) #368

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

getsize issue (pyfakefs returns, Python fails with OSError) #368

agroce opened this issue Apr 9, 2018 · 0 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 False:
    os0 = os
    opener0 = open
    shutil.rmtree(ROOT_PATH)
    os.mkdir(ROOT_PATH)

component0 = "alpha"
path0 = ROOT_PATH
path0 += os.path.sep + component0 
file0 = opener0(path0,'w') 
component0 = "" 
path0 += os.path.sep + component0
result = os0.path.getsize(path0) 

Python says:

Traceback (most recent call last):
  File "getsizebug.py", line 26, in <module>
    result = os0.path.getsize(path0) 
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py", line 57, in getsize
    return os.stat(filename).st_size
OSError: [Errno 20] Not a directory: '/Volumes/ramdisk/newtest/alpha/'
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