You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.3 KiB
67 lines
2.3 KiB
2 years ago
|
From 566dbd8bdde01514c5cf0802d03a9dca918b6e82 Mon Sep 17 00:00:00 2001
|
||
|
From: Zoltan Puskas <zoltan@sinustrom.info>
|
||
|
Date: Sat, 4 Dec 2021 12:59:37 -0800
|
||
|
Subject: [PATCH] Fix unit test test_trash_empty_will_skip_unreadable_dir
|
||
|
|
||
|
This patch fixes two issues with the current test:
|
||
|
- it prevents the test from breaking out of the test environment and
|
||
|
does not try to clean trash directories for all mount points
|
||
|
- it does actually test the "unreadable" directory
|
||
|
|
||
|
Bug: GH-217
|
||
|
---
|
||
|
tests/test_trash_empty.py | 25 +++++++++++++++++--------
|
||
|
1 file changed, 17 insertions(+), 8 deletions(-)
|
||
|
|
||
|
diff --git a/tests/test_trash_empty.py b/tests/test_trash_empty.py
|
||
|
index c7a987d..a2f87e6 100644
|
||
|
--- a/tests/test_trash_empty.py
|
||
|
+++ b/tests/test_trash_empty.py
|
||
|
@@ -15,26 +15,35 @@ from .support import MyPath
|
||
|
from trashcli.fs import FileSystemReader
|
||
|
from trashcli.fs import FileRemover
|
||
|
|
||
|
-from trashcli.empty import main as empty
|
||
|
-
|
||
|
|
||
|
@pytest.mark.slow
|
||
|
class TestTrashEmptyCmd(unittest.TestCase):
|
||
|
def setUp(self):
|
||
|
self.tmp_dir = MyPath.make_temp_dir()
|
||
|
self.unreadable_dir = self.tmp_dir / 'data/Trash/files/unreadable'
|
||
|
+ self.volumes_listing = Mock(spec=VolumesListing)
|
||
|
+ self.volumes_listing.list_volumes.return_value = [self.unreadable_dir]
|
||
|
+ self.err=StringIO()
|
||
|
+ self.empty = EmptyCmd(
|
||
|
+ out=StringIO(),
|
||
|
+ err=self.err,
|
||
|
+ environ={'XDG_DATA_HOME':self.tmp_dir / 'data'},
|
||
|
+ volumes_listing=self.volumes_listing,
|
||
|
+ now=None,
|
||
|
+ file_reader=FileSystemReader(),
|
||
|
+ getuid=lambda: 123,
|
||
|
+ file_remover=FileRemover(),
|
||
|
+ version=None,
|
||
|
+ volume_of=lambda x: "volume_of %s" % x
|
||
|
+ )
|
||
|
|
||
|
def test_trash_empty_will_skip_unreadable_dir(self):
|
||
|
- out = StringIO()
|
||
|
- err = StringIO()
|
||
|
-
|
||
|
make_unreadable_dir(self.unreadable_dir)
|
||
|
|
||
|
- empty(['trash-empty'], stdout = out, stderr = err,
|
||
|
- environ={'XDG_DATA_HOME':self.tmp_dir / 'data'})
|
||
|
+ self.empty.run('trash-empty')
|
||
|
|
||
|
assert ("trash-empty: cannot remove %s\n" % self.unreadable_dir ==
|
||
|
- err.getvalue())
|
||
|
+ self.err.getvalue())
|
||
|
|
||
|
def tearDown(self):
|
||
|
make_readable(self.unreadable_dir)
|
||
|
--
|
||
|
2.33.1
|
||
|
|