aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-05 22:50:25 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-07 16:40:15 -0700
commit4cfc2740b266ccaf8428c0d78c6d913480421d4c (patch)
tree67098a7cf9d244277070eebed0d5f5d33e650d18 /test
parentdeb2fa355a29c1101ab566c4036b0992e0c14aa9 (diff)
Turn tst_mknod() into tst_create()
Ensure that we are really creating a new file. Don't attempt to write, we do that in tst_open_write().
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_examples.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/test/test_examples.py b/test/test_examples.py
index 9bea3e9..686d8ba 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -84,8 +84,8 @@ def test_passthrough(tmpdir, name, debug):
tst_mkdir(work_dir)
tst_rmdir(src_dir, work_dir)
tst_open_write(src_dir, work_dir)
+ tst_create(work_dir)
tst_symlink(work_dir)
- tst_mknod(work_dir)
tst_unlink(src_dir, work_dir)
if os.getuid() == 0:
tst_chown(work_dir)
@@ -337,15 +337,22 @@ def tst_symlink(mnt_dir):
assert linkname in os.listdir(mnt_dir)
checked_unlink(linkname, mnt_dir)
-def tst_mknod(mnt_dir):
- filename = pjoin(mnt_dir, name_generator())
- shutil.copyfile(TEST_FILE, filename)
- fstat = os.lstat(filename)
+def tst_create(mnt_dir):
+ name = name_generator()
+ fullname = pjoin(mnt_dir, name)
+ 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)
+
+ fd = os.open(fullname, os.O_CREAT | os.O_RDWR)
+ os.close(fd)
+
+ assert name in os.listdir(mnt_dir)
+ fstat = os.lstat(fullname)
assert stat.S_ISREG(fstat.st_mode)
assert fstat.st_nlink == 1
- assert os.path.basename(filename) in os.listdir(mnt_dir)
- assert filecmp.cmp(TEST_FILE, filename, False)
- checked_unlink(filename, mnt_dir)
+ assert fstat.st_size == 0
def tst_chown(mnt_dir):
filename = pjoin(mnt_dir, name_generator())