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

Closing a file with different closefd modes fails #343

Closed
mrbean-bremen opened this issue Jan 11, 2018 · 0 comments
Closed

Closing a file with different closefd modes fails #343

mrbean-bremen opened this issue Jan 11, 2018 · 0 comments
Labels

Comments

@mrbean-bremen
Copy link
Member

This is basically code taken from tempfile (found this while working on the dynamic patcher):

def test_closing_file_with_different_close_mode(self):
    filename = self.make_path('test.txt')
    fd = self.os.open(filename, os.O_CREAT | os.O_RDWR | os.O_BINARY, 0o600)
    with self.open(fd, 'wb', closefd=False) as fp:
        fp.write(b'test')
    self.os.close(fd)
    self.assertTrue(fp.closed)

This fails in the fake implemenation (self.os / self.open being the fake implementation in this case) because the fd is not closed in the last close() call as it should have been.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jan 11, 2018
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jan 11, 2018
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

1 participant