aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-05 22:45:31 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-07 16:40:15 -0700
commitd4092d70db9e3bda52a80ea0c687ed0d0e110124 (patch)
tree4f8cecbb8c45540cffc29ad7a568e84f6e91aaf6 /test
parent68d9584e049c8f4a4c9c44797c6216588f248d9f (diff)
Added tst_unlink()
To check for unlink() support without requiring create()/mknod().
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_examples.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_examples.py b/test/test_examples.py
index 3bc3674..d7de380 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -86,6 +86,7 @@ def test_passthrough(tmpdir, name, debug):
tst_rmdir(src_dir, work_dir)
tst_symlink(work_dir)
tst_mknod(work_dir)
+ tst_unlink(src_dir, work_dir)
if os.getuid() == 0:
tst_chown(work_dir)
# Underlying fs may not have full nanosecond resolution
@@ -292,6 +293,18 @@ def checked_unlink(filename, path, isdir=False):
assert exc_info.value.errno == errno.ENOENT
assert filename not in os.listdir(path)
+def tst_unlink(src_dir, mnt_dir):
+ name = name_generator()
+ fullname = mnt_dir + "/" + name
+ with open(pjoin(src_dir, name), 'wb') as fh:
+ fh.write(b'hello')
+ assert name in os.listdir(mnt_dir)
+ os.unlink(fullname)
+ with pytest.raises(OSError) as exc_info:
+ os.stat(fullname)
+ assert exc_info.value.errno == errno.ENOENT
+ assert name not in os.listdir(mnt_dir)
+
def tst_mkdir(mnt_dir):
dirname = name_generator()
fullname = mnt_dir + "/" + dirname