aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-05 22:35:37 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-07 16:40:15 -0700
commit68d9584e049c8f4a4c9c44797c6216588f248d9f (patch)
tree6806eda1525d0b8955bafa124f932183a56e004e /test
parentaaa7a7c3b77796140fc9d9cbf271a751a8a77b00 (diff)
tst_mkdir(): factor out tst_rmdir()
This allows testing a filesystem that offers mkdir(), but no rmdir() (and vice versa).
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_examples.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/test_examples.py b/test/test_examples.py
index 76557ac..3bc3674 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -83,6 +83,7 @@ def test_passthrough(tmpdir, name, debug):
tst_write(work_dir)
tst_readdir(src_dir, work_dir)
tst_mkdir(work_dir)
+ tst_rmdir(src_dir, work_dir)
tst_symlink(work_dir)
tst_mknod(work_dir)
if os.getuid() == 0:
@@ -300,7 +301,17 @@ def tst_mkdir(mnt_dir):
assert os.listdir(fullname) == []
assert fstat.st_nlink in (1,2)
assert dirname in os.listdir(mnt_dir)
- checked_unlink(dirname, mnt_dir, isdir=True)
+
+def tst_rmdir(src_dir, mnt_dir):
+ name = name_generator()
+ fullname = mnt_dir + "/" + name
+ os.mkdir(pjoin(src_dir, name))
+ assert name in os.listdir(mnt_dir)
+ os.rmdir(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_symlink(mnt_dir):
linkname = name_generator()
@@ -354,8 +365,8 @@ def tst_open_unlink(mnt_dir):
name = pjoin(mnt_dir, name_generator())
data1 = b'foo'
data2 = b'bar'
- fullname = pjoin(mnt_dir, name)
- with open(fullname, 'wb+', buffering=0) as fh:
+
+ with open(pjoin(mnt_dir, name), 'wb+', buffering=0) as fh:
fh.write(data1)
checked_unlink(name, mnt_dir)
fh.write(data2)