Tuesday, September 25, 2018

Re: DEFAULT_FILE_STORAGE and tests



Il giorno giovedì 20 settembre 2018 15:25:23 UTC+2, sandro dentella ha scritto:
Hi,

I have a storage that create some thumbnail and is declared in some  models' fields. It's created inheriting from DEFAULT_FILE_STORAGE and it just works fine both in FileSystemStorage and in Aws.

For this project need the aws Storage (from Django_storages) but when testing I prefer the local FileSystemStorage, so my TEST_RUNNER sets the desired one as follows:



from django.conf import settings
from django.test.runner import DiscoverRunner


class GeneraliDiscoverRunner(DiscoverRunner):
   
def __init__(self, *args, **kwargs):
        settings
.DEFAULT_FILE_STORAGE = 'web.storage.TestStorage'
       
super().__init__(*args, **kwargs)

It seems that this changes the Storage in all situations apart from the fields declared in the models via the storage=ThumbnailStorage. I guess when model are read the settings from the runner has not yet been set. Is there a way to set the Storage in due time?


Thanks in advance
sandro
*:-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/15789ee1-034f-4658-b739-e92ead413e14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment