mirror of
https://github.com/arsenetar/send2trash.git
synced 2025-05-08 17:59:50 +00:00
Add a test case for a path containing a symlink.
This commit is contained in:
parent
798893215c
commit
eeaf4e8ffa
@ -4,7 +4,7 @@ from os import path as op
|
|||||||
import send2trash.plat_other
|
import send2trash.plat_other
|
||||||
from send2trash.plat_other import send2trash as s2t
|
from send2trash.plat_other import send2trash as s2t
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from tempfile import mkdtemp, NamedTemporaryFile
|
from tempfile import mkdtemp, NamedTemporaryFile, mktemp
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
# Could still use cleaning up. But no longer relies on ramfs.
|
# 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
|
os.chmod(self.trashTopdir, 0o700) # writable to allow deletion
|
||||||
TestExtVol.tearDown(self)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user