Added tst_unlink()
authorNikolaus Rath <Nikolaus@rath.org>
Thu, 6 Apr 2017 05:45:31 +0000 (22:45 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Fri, 7 Apr 2017 23:40:15 +0000 (16:40 -0700)
To check for unlink() support without requiring create()/mknod().

test/test_examples.py

index 3bc36743035ce2f4a39be10bdcb9f64ef2fb7c75..d7de380240505e6e56b220177012373ff6ed3b82 100755 (executable)
@@ -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