diff options
| author | Damien George <damien.p.george@gmail.com> | 2016-12-02 15:06:09 +1100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2016-12-02 15:06:09 +1100 |
| commit | b7df3e541a49a1cb72862c4015b6a883a63e1e29 (patch) | |
| tree | 34c338dbb2ea6da52398feccc1b17672abe92608 /tests/extmod | |
| parent | 08bd7d1d31a95331dad403adce8834c2d39ab3e8 (diff) | |
extmod/vfs_fat: Implement POSIX behaviour of rename, allow to overwrite.
If the destination of os.rename() exists then it will be overwritten if it
is a file. This is the POSIX behaviour, which is also the CPython
behaviour, and so we follow suit.
See issue #2598 for discussion.
Diffstat (limited to 'tests/extmod')
| -rw-r--r-- | tests/extmod/vfs_fat_fileio.py | 8 | ||||
| -rw-r--r-- | tests/extmod/vfs_fat_fileio.py.exp | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/extmod/vfs_fat_fileio.py b/tests/extmod/vfs_fat_fileio.py index de8d4953c..4e0dc6019 100644 --- a/tests/extmod/vfs_fat_fileio.py +++ b/tests/extmod/vfs_fat_fileio.py @@ -140,6 +140,14 @@ print(vfs.listdir("foo_dir")) vfs.rename("foo_dir/file.txt", "moved-to-root.txt") print(vfs.listdir()) +# check that renaming to existing file will overwrite it +with vfs.open("temp", "w") as f: + f.write("new text") +vfs.rename("temp", "moved-to-root.txt") +print(vfs.listdir()) +with vfs.open("moved-to-root.txt") as f: + print(f.read()) + # valid removes vfs.remove("foo_dir/sub_file.txt") vfs.remove("foo_file.txt") diff --git a/tests/extmod/vfs_fat_fileio.py.exp b/tests/extmod/vfs_fat_fileio.py.exp index c438bc850..4e34e83a8 100644 --- a/tests/extmod/vfs_fat_fileio.py.exp +++ b/tests/extmod/vfs_fat_fileio.py.exp @@ -18,5 +18,7 @@ b'data in file' True ['sub_file.txt', 'file.txt'] ['foo_file.txt', 'foo_dir', 'moved-to-root.txt'] +['foo_file.txt', 'foo_dir', 'moved-to-root.txt'] +new text ['moved-to-root.txt'] ENOSPC: True |
