Fixed #22299 -- Cleanup wizard temp files when possible. #2451

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

charettes commented Mar 21, 2014

No description provided.

Member

erikr commented Mar 21, 2014

The tests fail on Python 3.3:

----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/erik/dev/django/django/contrib/formtools/tests/wizard/storage.py", line 101, in test_reset_deletes_tmp_files
    file_ = SimpleUploadedFile('file.txt', 'content')
  File "/Users/erik/dev/django/django/core/files/uploadedfile.py", line 117, in __init__
    super(SimpleUploadedFile, self).__init__(BytesIO(content), None, name,
TypeError: 'str' does not support the buffer interface

======================================================================
ERROR: test_reset_deletes_tmp_files (django.contrib.formtools.tests.wizard.test_sessionstorage.TestSessionStorage)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/erik/dev/django/django/contrib/formtools/tests/wizard/storage.py", line 101, in test_reset_deletes_tmp_files
    file_ = SimpleUploadedFile('file.txt', 'content')
  File "/Users/erik/dev/django/django/core/files/uploadedfile.py", line 117, in __init__
    super(SimpleUploadedFile, self).__init__(BytesIO(content), None, name,
TypeError: 'str' does not support the buffer interface

@erikr erikr commented on an outdated diff Mar 21, 2014

docs/ref/contrib/formtools/form-wizard.txt
@@ -630,8 +630,8 @@ storage class <builtin-fs-storage>`)::
.. warning::
Please remember to take care of removing old files as the
- :class:`WizardView` won't remove any files, whether the wizard gets
- finished correctly or not.
+ :class:`WizardView` won't remove any files if the wizard isn't finished
@erikr

erikr Mar 21, 2014

Member

This leans towards a double negative, I'd rephrase it as:

    Please remember to take care of removing old temporary files, as the
    :class:`WizardView` will only remove these files if the wizard finishes
    correctly.

@charettes charettes commented on the diff Mar 21, 2014

django/contrib/formtools/tests/wizard/storage.py
@@ -85,3 +92,17 @@ def test_extra_context_key_persistence(self):
storage.extra_data['test'] = True
self.assertTrue('test' in storage.extra_data)
+
+ def test_reset_deletes_tmp_files(self):
+ request = get_request()
+ storage = self.get_storage()('wizard1', request, temp_storage)
+
+ step = 'start'
+ file_ = SimpleUploadedFile('file.txt', b'content')
@charettes

charettes Mar 21, 2014

Member

This should fix the Python 3 failure.

Member

charettes commented Mar 21, 2014

Thanks @erikr, fixed the test failure on Python 3 and rephrased documentation as you suggested.

charettes closed this Mar 23, 2014

charettes deleted the charettes:wizard-tmp-files branch Aug 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment