Opened 7 months ago

Last modified 3 months ago

#23251 new Bug

Use a temporary folder to store uploaded files during tests

Reported by: shai Owned by:
Component: Testing framework Version: master
Severity: Normal Keywords: file storage upload
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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:

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.

Change History (4)

comment:1 Changed 7 months ago by timgraham

  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 months ago by pavel_shpilev

  • Owner changed from nobody to pavel_shpilev
  • Status changed from new to assigned

comment:3 Changed 3 months ago by berkerpeksag

  • Needs documentation unset
  • Needs tests unset

Pavel, do you working on this? If not, I can take a look at this.

comment:4 Changed 3 months ago by pavel_shpilev

  • Owner pavel_shpilev deleted
  • Status changed from assigned to new

Oops, sorry. I was sure I deassigned myself.
Please, feel free to take it over.

Note: See TracTickets for help on using tickets.
Back to Top