mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
tests: Update ZulipTestCase.tearDown to remove local uploads.
Previously, tests that exercised code paths that added local uploads did not always clean up `settings.LOCAL_UPLOADS_DIR` after the test was complete. Updates the `ZulipTestCase` class to remove any local uploads in the unique `settings.LOCAL_UPLOADS_DIR` in `tearDown` for all tests.
This commit is contained in:
committed by
Tim Abbott
parent
a6fd41e012
commit
7b225245c0
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import urllib
|
||||
from io import StringIO
|
||||
from urllib.parse import urlparse
|
||||
@@ -39,12 +38,6 @@ from zerver.models import (
|
||||
)
|
||||
|
||||
|
||||
def destroy_uploads() -> None:
|
||||
assert settings.LOCAL_UPLOADS_DIR is not None
|
||||
if os.path.exists(settings.LOCAL_UPLOADS_DIR):
|
||||
shutil.rmtree(settings.LOCAL_UPLOADS_DIR)
|
||||
|
||||
|
||||
class LocalStorageTest(UploadSerializeMixin, ZulipTestCase):
|
||||
def test_upload_message_attachment(self) -> None:
|
||||
user_profile = self.example_user("hamlet")
|
||||
@@ -269,7 +262,3 @@ class LocalStorageTest(UploadSerializeMixin, ZulipTestCase):
|
||||
)
|
||||
path_id = urllib.parse.urlparse(uri).path
|
||||
self.assertEqual(delete_export_tarball(path_id), path_id)
|
||||
|
||||
def tearDown(self) -> None:
|
||||
destroy_uploads()
|
||||
super().tearDown()
|
||||
|
||||
Reference in New Issue
Block a user