mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Refs #26029 -- Removed DEFAULT_FILE_STORAGE and STATICFILES_STORAGE settings.
This also removes django.core.files.storage.get_storage_class(). Per deprecation timeline.
This commit is contained in:
parent
3a3e737694
commit
f72f420f17
16 changed files with 39 additions and 556 deletions
|
@ -15,18 +15,9 @@ from django.conf import DEFAULT_STORAGE_ALIAS, STATICFILES_STORAGE_ALIAS
|
|||
from django.core.cache import cache
|
||||
from django.core.exceptions import SuspiciousFileOperation
|
||||
from django.core.files.base import ContentFile, File
|
||||
from django.core.files.storage import (
|
||||
GET_STORAGE_CLASS_DEPRECATED_MSG,
|
||||
FileSystemStorage,
|
||||
InvalidStorageError,
|
||||
)
|
||||
from django.core.files.storage import FileSystemStorage, InvalidStorageError
|
||||
from django.core.files.storage import Storage as BaseStorage
|
||||
from django.core.files.storage import (
|
||||
StorageHandler,
|
||||
default_storage,
|
||||
get_storage_class,
|
||||
storages,
|
||||
)
|
||||
from django.core.files.storage import StorageHandler, default_storage, storages
|
||||
from django.core.files.uploadedfile import (
|
||||
InMemoryUploadedFile,
|
||||
SimpleUploadedFile,
|
||||
|
@ -35,11 +26,10 @@ from django.core.files.uploadedfile import (
|
|||
from django.db.models import FileField
|
||||
from django.db.models.fields.files import FileDescriptor
|
||||
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings
|
||||
from django.test.utils import ignore_warnings, requires_tz_support
|
||||
from django.test.utils import requires_tz_support
|
||||
from django.urls import NoReverseMatch, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils._os import symlinks_supported
|
||||
from django.utils.deprecation import RemovedInDjango51Warning
|
||||
|
||||
from .models import (
|
||||
Storage,
|
||||
|
@ -52,51 +42,6 @@ from .models import (
|
|||
FILE_SUFFIX_REGEX = "[A-Za-z0-9]{7}"
|
||||
|
||||
|
||||
class GetStorageClassTests(SimpleTestCase):
|
||||
@ignore_warnings(category=RemovedInDjango51Warning)
|
||||
def test_get_filesystem_storage(self):
|
||||
"""
|
||||
get_storage_class returns the class for a storage backend name/path.
|
||||
"""
|
||||
self.assertEqual(
|
||||
get_storage_class("django.core.files.storage.FileSystemStorage"),
|
||||
FileSystemStorage,
|
||||
)
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango51Warning)
|
||||
def test_get_invalid_storage_module(self):
|
||||
"""
|
||||
get_storage_class raises an error if the requested import don't exist.
|
||||
"""
|
||||
with self.assertRaisesMessage(ImportError, "No module named 'storage'"):
|
||||
get_storage_class("storage.NonexistentStorage")
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango51Warning)
|
||||
def test_get_nonexistent_storage_class(self):
|
||||
"""
|
||||
get_storage_class raises an error if the requested class don't exist.
|
||||
"""
|
||||
with self.assertRaises(ImportError):
|
||||
get_storage_class("django.core.files.storage.NonexistentStorage")
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango51Warning)
|
||||
def test_get_nonexistent_storage_module(self):
|
||||
"""
|
||||
get_storage_class raises an error if the requested module don't exist.
|
||||
"""
|
||||
with self.assertRaisesMessage(
|
||||
ImportError, "No module named 'django.core.files.nonexistent_storage'"
|
||||
):
|
||||
get_storage_class(
|
||||
"django.core.files.nonexistent_storage.NonexistentStorage"
|
||||
)
|
||||
|
||||
def test_deprecation_warning(self):
|
||||
msg = GET_STORAGE_CLASS_DEPRECATED_MSG
|
||||
with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
|
||||
get_storage_class("django.core.files.storage.FileSystemStorage")
|
||||
|
||||
|
||||
class FileSystemStorageTests(unittest.TestCase):
|
||||
def test_deconstruction(self):
|
||||
path, args, kwargs = temp_storage.deconstruct()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue