How to use the send2trash.plat_other.HOMETRASH 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
from os import path as op
import send2trash.plat_other
from send2trash.plat_other import send2trash as s2t
from send2trash.compat import PY3
try:
    from configparser import ConfigParser
except ImportError:
    # py2
    from ConfigParser import ConfigParser
from tempfile import mkdtemp, NamedTemporaryFile, mktemp
import shutil
import stat
import sys
# Could still use cleaning up. But no longer relies on ramfs.

HOMETRASH = send2trash.plat_other.HOMETRASH

def touch(path):
    with open(path, 'a'):
        os.utime(path, None)

class TestHomeTrash(unittest.TestCase):
    def setUp(self):
        self.file = NamedTemporaryFile(
            dir=op.expanduser("~"), prefix='send2trash_test', delete=False)

    def test_trash(self):
        s2t(self.file.name)
        self.assertFalse(op.exists(self.file.name))

    def tearDown(self):
        name = op.basename(self.file.name)