From eeaf4e8ffa9cdaf17ec56986f65648027fb76a4f Mon Sep 17 00:00:00 2001 From: gbn Date: Sun, 13 Mar 2011 15:17:13 -0400 Subject: [PATCH] Add a test case for a path containing a symlink. --- test_plat_other.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test_plat_other.py b/test_plat_other.py index da9517e..9b6ae31 100644 --- a/test_plat_other.py +++ b/test_plat_other.py @@ -4,7 +4,7 @@ from os import path as op import send2trash.plat_other from send2trash.plat_other import send2trash as s2t from configparser import ConfigParser -from tempfile import mkdtemp, NamedTemporaryFile +from tempfile import mkdtemp, NamedTemporaryFile, mktemp import shutil import stat # Could still use cleaning up. But no longer relies on ramfs. @@ -104,5 +104,23 @@ class TestTopdirFailure(TestExtVol): os.chmod(self.trashTopdir, 0o700) # writable to allow deletion TestExtVol.tearDown(self) +# Make sure it will find the mount point properly for a file in a symlinked path +class TestSymlink(TestExtVol): + def setUp(self): + TestExtVol.setUp(self) + # Use mktemp (race conditioney but no symlink equivalent) + # Since is_parent uses realpath(), and our getdev uses is_parent, + # this should work + self.slDir = mktemp(prefix='s2t', dir=op.expanduser('~')) + os.symlink(self.trashTopdir, self.slDir) + + def test_trash(self): + s2t(op.join(self.slDir, self.fileName)) + self.assertFalse(op.exists(self.filePath)) + + def tearDown(self): + os.remove(self.slDir) + TestExtVol.tearDown(self) + if __name__ == '__main__': unittest.main()