Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Add: Ability to specifically remove temporary directories that have been used by a unit test

Wolf-Bastian Poettnerdb6f423ca734
diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.py
index 1dbe1ca18..50f3fe485 100644
--- a/src/documents/tests/test_file_handling.py
+++ b/src/documents/tests/test_file_handling.py
@@ -15,18 +15,14 @@ from django.conf import settings
class TestDate(TestCase):
- def tearDown(self):
- # Delete all temporary directories from failed tests
- root = os.path.normpath("/tmp")
-
- for filename in os.listdir(root):
- fullname = os.path.join(root, filename)
+ deletion_list = []
- if not os.path.isdir(fullname):
- continue
+ def add_to_deletion_list(self, dirname):
+ self.deletion_list.append(dirname)
- if filename.startswith("paperless-tests-"):
- shutil.rmtree(fullname, ignore_errors=True)
+ def tearDown(self):
+ for dirname in self.deletion_list:
+ shutil.rmtree(dirname, ignore_errors=True)
@override_settings(PAPERLESS_FILENAME_FORMAT="")
def test_source_filename(self):