#23251: Use a temporary folder to store uploaded files during tests
-------------------------------------+-------------------------------------
Reporter: shai | Owner: nobody
Type: Bug | Status: new
Component: Testing | Version: master
framework | Keywords: file storage upload
Severity: Normal | Has patch: 0
Triage Stage: | Needs tests: 1
Unreviewed | Easy pickings: 0
Needs documentation: 1 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Today, when running tests, Django uses the production storage for uploaded
files -- meaning any tests which upload files will save copies of them,
under different names, for every test run.
We need to treat this essentially like we treat mail -- during tests, a
special file-storage should be set up to receive the uploads. Like with
mail, it is probably better for this folder to be kept after the test run
ends, and be cleared only when the tests are run again; but this is of
lower priority.
This should be the default, or enabled easily in settings.
As @apollo13 noted, Django's own tests define an environment variable:
{{{#!python
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
}}}
and all storages used in the suite use it or a subfolder. This alone,
however, is not enough for user tests, as there is currently no way to
define separate storages for test and production.
--
Ticket URL: <https://code.djangoproject.com/ticket/23251>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.c30e1b8d25592155d8461dc2534cadb7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.