From deb2fa355a29c1101ab566c4036b0992e0c14aa9 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Wed, 5 Apr 2017 22:48:00 -0700 Subject: Renamed tst_write() to tst_open_write() We are actually testing both opening of an existing file and writing to it. --- test/test_examples.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/test_examples.py b/test/test_examples.py index d7de380..9bea3e9 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -80,10 +80,10 @@ def test_passthrough(tmpdir, name, debug): subprocess.check_call([ os.path.join(basename, 'test', 'test_syscalls'), work_dir, ':' + src_dir ]) - tst_write(work_dir) tst_readdir(src_dir, work_dir) tst_mkdir(work_dir) tst_rmdir(src_dir, work_dir) + tst_open_write(src_dir, work_dir) tst_symlink(work_dir) tst_mknod(work_dir) tst_unlink(src_dir, work_dir) @@ -367,12 +367,17 @@ def tst_chown(mnt_dir): assert fstat.st_gid == gid_new checked_unlink(filename, mnt_dir, isdir=True) - -def tst_write(mnt_dir): - name = pjoin(mnt_dir, name_generator()) - shutil.copyfile(TEST_FILE, name) - assert filecmp.cmp(name, TEST_FILE, False) - checked_unlink(name, mnt_dir) +def tst_open_write(src_dir, mnt_dir): + name = name_generator() + fd = os.open(pjoin(src_dir, name), + os.O_CREAT | os.O_RDWR) + os.close(fd) + fullname = pjoin(mnt_dir, name) + with open(fullname, 'wb') as fh_out, \ + open(TEST_FILE, 'rb') as fh_in: + shutil.copyfileobj(fh_in, fh_out) + + assert filecmp.cmp(fullname, TEST_FILE, False) def tst_open_unlink(mnt_dir): name = pjoin(mnt_dir, name_generator()) -- cgit v1.2.3