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

python3 - io.open not redirected to fake file system #70

Closed
jopalach opened this issue Jan 23, 2016 · 0 comments · Fixed by #109
Closed

python3 - io.open not redirected to fake file system #70

jopalach opened this issue Jan 23, 2016 · 0 comments · Fixed by #109

Comments

@jopalach
Copy link

def setUp(self):
    self.setUpPyfakefs()
    # Fix for python 3+; except 3.2
    #io.open = open

def test_willRedirectIoOpen(self):
     os.makedirs('install')
     file = os.path.join('install', 'sample.txt')
        with io.open(file, 'w'):
            pass
    self.assertTrue(os.path.exists(file))

this causes the following error: IOError: [Errno 2] No such file or directory: 'install\sample.txt'

Monkey patching io.open to open after setting up the fake file system seems to fix the problem for all python versions with the exception of 3.2

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jun 12, 2016
- redirects to FakeFileOpen
- fixes pytest-dev#70 and pytest-dev#103
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jun 12, 2016
- redirects to FakeFileOpen
- fixes pytest-dev#70 and pytest-dev#103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants