diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py b/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py
index fa9071d..9352ae9 100644
a
|
b
|
class ContactWizard(NamedUrlWizardView):
|
50 | 50 | |
51 | 51 | |
52 | 52 | class SessionContactWizard(ContactWizard): |
53 | | storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' |
| 53 | storage_name = 'django.contrib.formtools.tests.wizard.storage.WrappedSessionStorage' |
54 | 54 | |
55 | 55 | |
56 | 56 | class CookieContactWizard(ContactWizard): |
57 | | storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' |
| 57 | storage_name = 'django.contrib.formtools.tests.wizard.storage.WrappedCookieStorage' |
diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py b/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
index b6125db..7a595fa 100644
a
|
b
|
from django.contrib.auth.tests.utils import skipIfCustomUser
|
9 | 9 | |
10 | 10 | from django.contrib.formtools.wizard.views import (NamedUrlSessionWizardView, |
11 | 11 | NamedUrlCookieWizardView) |
| 12 | from django.contrib.formtools.tests.wizard.storage import TrackingFilesMixin |
12 | 13 | from django.contrib.formtools.tests.wizard.test_forms import get_request, Step1, Step2 |
13 | 14 | |
14 | 15 | |
… |
… |
class NamedWizardTests(object):
|
19 | 20 | self.testuser, created = User.objects.get_or_create(username='testuser1') |
20 | 21 | self.wizard_step_data[0]['form1-user'] = self.testuser.pk |
21 | 22 | |
| 23 | def tearDown(self): |
| 24 | for uploaded_file in TrackingFilesMixin.open_files: |
| 25 | uploaded_file.close() |
| 26 | TrackingFilesMixin.open_files = [] |
| 27 | |
22 | 28 | def test_initial_call(self): |
23 | 29 | response = self.client.get(reverse('%s_start' % self.wizard_urlname)) |
24 | 30 | self.assertEqual(response.status_code, 302) |
diff --git a/django/contrib/formtools/tests/wizard/storage.py b/django/contrib/formtools/tests/wizard/storage.py
index c54ed9a..d157b95 100644
a
|
b
|
from django.http import HttpRequest
|
5 | 5 | from django.conf import settings |
6 | 6 | |
7 | 7 | from django.contrib.auth.models import User |
| 8 | from django.contrib.formtools.wizard.storage.cookie import CookieStorage |
| 9 | from django.contrib.formtools.wizard.storage.session import SessionStorage |
8 | 10 | |
9 | 11 | |
10 | 12 | def get_request(): |
… |
… |
class TestStorage(object):
|
85 | 87 | storage.extra_data['test'] = True |
86 | 88 | |
87 | 89 | self.assertTrue('test' in storage.extra_data) |
| 90 | |
| 91 | |
| 92 | class TrackingFilesMixin(object): |
| 93 | """ |
| 94 | Keep track of open UploadedFiles to be able to properly close them to |
| 95 | silence ResourceWarning on Python 3. |
| 96 | """ |
| 97 | open_files = [] |
| 98 | def get_step_files(self, step): |
| 99 | files = super(TrackingFilesMixin, self).get_step_files(step) |
| 100 | if files is not None: |
| 101 | self.open_files.extend(list(files.values())) |
| 102 | return files |
| 103 | |
| 104 | |
| 105 | class WrappedCookieStorage(TrackingFilesMixin, CookieStorage): |
| 106 | pass |
| 107 | |
| 108 | |
| 109 | class WrappedSessionStorage(TrackingFilesMixin, SessionStorage): |
| 110 | pass |
diff --git a/django/contrib/formtools/tests/wizard/wizardtests/forms.py b/django/contrib/formtools/tests/wizard/wizardtests/forms.py
index 5e4617c..d922d4c 100644
a
|
b
|
UserFormSet = modelformset_factory(User, form=UserForm)
|
65 | 65 | |
66 | 66 | |
67 | 67 | class SessionContactWizard(ContactWizard): |
68 | | storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' |
| 68 | storage_name = 'django.contrib.formtools.tests.wizard.storage.WrappedSessionStorage' |
69 | 69 | |
70 | 70 | |
71 | 71 | class CookieContactWizard(ContactWizard): |
72 | | storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' |
| 72 | storage_name = 'django.contrib.formtools.tests.wizard.storage.WrappedCookieStorage' |
diff --git a/django/contrib/formtools/tests/wizard/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
index 22c5b2b..f64d424 100644
a
|
b
|
from django.contrib.auth.tests.utils import skipIfCustomUser
|
11 | 11 | from django.contrib.formtools.wizard.views import CookieWizardView |
12 | 12 | from django.utils._os import upath |
13 | 13 | from django.contrib.formtools.tests.models import Poet, Poem |
| 14 | from django.contrib.formtools.tests.wizard.storage import TrackingFilesMixin |
14 | 15 | |
15 | 16 | |
16 | 17 | class UserForm(forms.ModelForm): |
… |
… |
class WizardTests(object):
|
30 | 31 | self.testuser, created = User.objects.get_or_create(username='testuser1') |
31 | 32 | self.wizard_step_data[0]['form1-user'] = self.testuser.pk |
32 | 33 | |
| 34 | def tearDown(self): |
| 35 | for uploaded_file in TrackingFilesMixin.open_files: |
| 36 | uploaded_file.close() |
| 37 | TrackingFilesMixin.open_files = [] |
| 38 | |
33 | 39 | def test_initial_call(self): |
34 | 40 | response = self.client.get(self.wizard_url) |
35 | 41 | wizard = response.context['wizard'] |