Exemplo n.º 1
0
 def test_trash(self):
     s2t(op.join(self.slDir, self.fileName))
     self.assertFalse(op.exists(self.filePath))
     self.assertTrue(
         op.exists(
             op.join(self.trashTopdir, '.Trash-' + str(os.getuid()),
                     'files', self.fileName)))
Exemplo n.º 2
0
 def test_trash(self):
     s2t(self.filePath)
     self.assertFalse(op.exists(self.filePath))
     self.assertTrue(op.exists(op.join(self.trashDir, str(os.getuid()), 'files', self.fileName)))
     self.assertTrue(op.exists(op.join(self.trashDir, str(os.getuid()), 'info', self.fileName + '.trashinfo')))
     # info relative path (if another test is added, with the same fileName/Path,
     # then it gets renamed etc.)
     cfg = ConfigParser()
     cfg.read(op.join(self.trashDir, str(os.getuid()), 'info', self.fileName + '.trashinfo'))
     self.assertEqual(self.fileName, cfg.get('Trash Info', 'Path', raw=True))
Exemplo n.º 3
0
def test_trash_topdir_fallback(testExtVol):
    s2t(testExtVol[2])
    assert op.exists(testExtVol[2]) is False
    assert (op.exists(
        op.join(
            testExtVol[0].trashTopdir,
            ".Trash-" + str(os.getuid()),
            "files",
            testExtVol[1],
        )) is True)
Exemplo n.º 4
0
 def test_trash(self):
     touch(self.filePath)
     s2t(self.filePath)
     self.assertFalse(op.exists(self.filePath))
     self.assertTrue(
         op.exists(
             op.join(
                 self.trashTopdir,
                 ".Trash-" + str(os.getuid()),
                 "files",
                 self.fileName,
             )))
Exemplo n.º 5
0
def test_trash_symlink(testExtVol):
    # Use mktemp (race conditioney but no symlink equivalent)
    # Since is_parent uses realpath(), and our getdev uses is_parent,
    # this should work
    slDir = mktemp(prefix="s2t", dir=op.expanduser("~"))
    os.mkdir(op.join(testExtVol[0].trashTopdir, "subdir"), 0o700)
    filePath = op.join(testExtVol[0].trashTopdir, "subdir", testExtVol[1])
    touch(filePath)
    os.symlink(op.join(testExtVol[0].trashTopdir, "subdir"), slDir)
    s2t(op.join(slDir, testExtVol[1]))
    assert op.exists(filePath) is False
    assert (op.exists(
        op.join(
            testExtVol[0].trashTopdir,
            ".Trash-" + str(os.getuid()),
            "files",
            testExtVol[1],
        )) is True)
    os.remove(slDir)
Exemplo n.º 6
0
def test_trash_topdir(testExtVol):
    trashDir = op.join(testExtVol[0].trashTopdir, ".Trash")
    os.mkdir(trashDir, 0o777 | stat.S_ISVTX)

    s2t(testExtVol[2])
    assert op.exists(testExtVol[2]) is False
    assert (op.exists(
        op.join(trashDir, str(os.getuid()), "files", testExtVol[1])) is True)
    assert (op.exists(
        op.join(
            trashDir,
            str(os.getuid()),
            "info",
            testExtVol[1] + ".trashinfo",
        )) is True)
    # info relative path (if another test is added, with the same fileName/Path,
    # then it gets renamed etc.)
    cfg = ConfigParser()
    cfg.read(
        op.join(trashDir, str(os.getuid()), "info",
                testExtVol[1] + ".trashinfo"))
    assert (testExtVol[1] == cfg.get("Trash Info", "Path", raw=True)) is True
Exemplo n.º 7
0
 def test_trash_unicode(self):
     s2t(self.file.decode(sys.getfilesystemencoding()))
     assert not op.exists(self.file)
Exemplo n.º 8
0
 def test_trash_bytes(self):
     s2t(self.file)
     assert not op.exists(self.file)
Exemplo n.º 9
0
 def test_trash(self):
     s2t(self.file.name)
     self.assertFalse(op.exists(self.file.name))
Exemplo n.º 10
0
 def test_trash(self):
     s2t(op.join(self.slDir, self.fileName))
     self.assertFalse(op.exists(self.filePath))
     self.assertTrue(op.exists(op.join(self.trashTopdir, '.Trash-' + str(os.getuid()), 'files', self.fileName)))
Exemplo n.º 11
0
 def test_trash(self):
     with self.assertRaises(OSError):
         s2t(self.filePath)
     self.assertTrue(op.exists(self.filePath))
Exemplo n.º 12
0
 def test_multitrash(self):
     filenames = [file.name for file in self.files]
     s2t(filenames)
     self.assertFalse(any([op.exists(filename) for filename in filenames]))
Exemplo n.º 13
0
def test_multitrash(testfiles):
    filenames = [file.name for file in testfiles]
    s2t(filenames)
    assert any([op.exists(filename) for filename in filenames]) is False
Exemplo n.º 14
0
def test_trash(testfile):
    s2t(testfile.name)
    assert op.exists(testfile.name) is False
Exemplo n.º 15
0
def test_trash_bytes(testUnicodefile):
    s2t(testUnicodefile)
    assert not op.exists(testUnicodefile)