From d4092d70db9e3bda52a80ea0c687ed0d0e110124 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Wed, 5 Apr 2017 22:45:31 -0700 Subject: Added tst_unlink() To check for unlink() support without requiring create()/mknod(). --- test/test_examples.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/test_examples.py') 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 -- cgit v1.2.3