def test_trash_outside_prefix(self): tmp_dir = tempfile.mkdtemp() rel = relpath(tmp_dir, context.root_dir) self.assertTrue(rel.startswith(u'..')) move_path_to_trash(tmp_dir) self.assertFalse(exists(tmp_dir)) makedirs(tmp_dir) move_path_to_trash(tmp_dir) self.assertFalse(exists(tmp_dir))
def test_trash_outside_prefix(self): tmp_dir = tempfile.mkdtemp() rel = relpath(tmp_dir, context.root_dir) self.assertTrue(rel.startswith(u'..')) move_path_to_trash(tmp_dir) self.assertFalse(exists(tmp_dir)) makedirs(tmp_dir) move_path_to_trash(tmp_dir) self.assertFalse(exists(tmp_dir))
def test_move_path_to_trash_couldnt(): from conda.gateways.disk.delete import move_path_to_trash with tempdir() as td: test_path = join(td, 'test_path') touch(test_path) _try_open(test_path) assert isdir(td) assert isfile(test_path) assert move_path_to_trash(test_path)