How to use the send2trash.plat_other.get_dev function in Send2Trash

To help you get started, we’ve selected a few Send2Trash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hsoft / send2trash / tests / test_plat_other.py View on Github external
self.old_ismount = old_ismount = op.ismount
        self.old_getdev = send2trash.plat_other.get_dev
        def s_getdev(path):
            from send2trash.plat_other import is_parent
            st = os.lstat(path)
            if is_parent(self.trashTopdir, path):
                return 'dev'
            return st.st_dev
        def s_ismount(path):
            if op.realpath(path) in (op.realpath(self.trashTopdir), op.realpath(trashTopdir_b)):
                return True
            return old_ismount(path)

        send2trash.plat_other.os.path.ismount = s_ismount
        send2trash.plat_other.get_dev = s_getdev
github hsoft / send2trash / tests / test_plat_other.py View on Github external
def setUp(self):
        self.trashTopdir = mkdtemp(prefix='s2t')
        if PY3:
            trashTopdir_b = os.fsencode(self.trashTopdir)
        else:
            trashTopdir_b = self.trashTopdir
        self.fileName = 'test.txt'
        self.filePath = op.join(self.trashTopdir, self.fileName)
        touch(self.filePath)

        self.old_ismount = old_ismount = op.ismount
        self.old_getdev = send2trash.plat_other.get_dev
        def s_getdev(path):
            from send2trash.plat_other import is_parent
            st = os.lstat(path)
            if is_parent(self.trashTopdir, path):
                return 'dev'
            return st.st_dev
        def s_ismount(path):
            if op.realpath(path) in (op.realpath(self.trashTopdir), op.realpath(trashTopdir_b)):
                return True
            return old_ismount(path)

        send2trash.plat_other.os.path.ismount = s_ismount
        send2trash.plat_other.get_dev = s_getdev
github hsoft / send2trash / tests / test_plat_other.py View on Github external
def tearDown(self):
        send2trash.plat_other.get_dev = self.old_getdev
        send2trash.plat_other.os.path.ismount = self.old_ismount
        shutil.rmtree(self.trashTopdir)