Skip to content

Commit

Permalink
Make sure adding object to a symlinked directory works
Browse files Browse the repository at this point in the history
- see #215
  • Loading branch information
mrbean-bremen committed Jun 17, 2017
1 parent c5a5dae commit 1924447
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CHANGES.md
Expand Up @@ -5,15 +5,16 @@ The release versions are PyPi releases.

#### New Features
* Added support for basic modes in fake `os.open()` ([#204](../../issues/204)).
* Added fake `os.path.samefile` implementation ([#193](../../issues/193))
* Added fake `os.path.samefile` implementation ([#193](../../issues/193)).
* Added support for `ns` argument in `os.utime()` (Python >= 3.3) ([#192](../../issues/192)).
* Added nanosecond time members in `os.stat_result` (Python >= 3.3) ([#196](../../issues/196)).

#### Infrastructure

#### Fixes
* Incorrect error handling during directory creation ([#209](../../issues/209))
* Creating files in read-only directory was possible ([#203](../../issues/203))
* Failed to create directory with symlink as parent ([#215](../../issues/215)).
* Incorrect error handling during directory creation ([#209](../../issues/209)).
* Creating files in read-only directory was possible ([#203](../../issues/203)).

## [Version 3.2](https://pypi.python.org/pypi/pyfakefs/3.2)

Expand Down
9 changes: 9 additions & 0 deletions fake_filesystem_test.py
Expand Up @@ -1457,6 +1457,15 @@ def testMkdirRaisesIfParentIsReadOnly(self):
directory = '/a/b'
self.assertRaises(Exception, self.os.mkdir, directory)

def testMkdirWithWithSymlinkParent(self):
dir_path = '/foo/bar'
self.filesystem.CreateDirectory(dir_path)
link_path = '/foo/link'
self.os.symlink(dir_path, link_path)
new_dir = link_path + '/new_dir'
self.os.mkdir(new_dir)
self.assertTrue(self.filesystem.Exists(new_dir))

def testMakedirs(self):
"""makedirs can create a directory even if parent does not exist."""
parent = 'xyzzy'
Expand Down
5 changes: 4 additions & 1 deletion pyfakefs/fake_filesystem.py
Expand Up @@ -1773,7 +1773,10 @@ def AddObject(self, file_path, file_object):
IOError: if file_path does not correspond to a directory.
"""
try:
target_directory = self.GetObject(file_path)
if not file_path:
target_directory = self.root
else:
target_directory = self.ResolveObject(file_path)
target_directory.AddEntry(file_object)
except AttributeError:
raise IOError(errno.ENOTDIR,
Expand Down

0 comments on commit 1924447

Please sign in to comment.