summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_error_messages.py8
-rw-r--r--tests/forms_tests/tests/test_extra.py4
-rw-r--r--tests/forms_tests/tests/test_formsets.py14
-rw-r--r--tests/forms_tests/tests/tests.py8
4 files changed, 10 insertions, 24 deletions
diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
index 818556ce7f..5863b457f4 100644
--- a/tests/forms_tests/tests/test_error_messages.py
+++ b/tests/forms_tests/tests/test_error_messages.py
@@ -194,7 +194,7 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
'required': 'REQUIRED',
'invalid': 'INVALID IP ADDRESS',
}
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField(error_messages=e)
self.assertFormErrors(['REQUIRED'], f.clean, '')
@@ -243,9 +243,9 @@ class ModelChoiceFieldErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
def test_modelchoicefield(self):
# Create choices for the model choice field tests below.
from forms_tests.models import ChoiceModel
- c1 = ChoiceModel.objects.create(pk=1, name='a')
- c2 = ChoiceModel.objects.create(pk=2, name='b')
- c3 = ChoiceModel.objects.create(pk=3, name='c')
+ ChoiceModel.objects.create(pk=1, name='a')
+ ChoiceModel.objects.create(pk=2, name='b')
+ ChoiceModel.objects.create(pk=3, name='c')
# ModelChoiceField
e = {
diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py
index 8754c2f2e2..f32c764a1e 100644
--- a/tests/forms_tests/tests/test_extra.py
+++ b/tests/forms_tests/tests/test_extra.py
@@ -535,7 +535,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self.assertEqual(f.cleaned_data['field1'], 'some text,JP,2007-04-25 06:24:00')
def test_ipaddress(self):
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField()
self.assertFormErrors(['This field is required.'], f.clean, '')
@@ -546,7 +546,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self.assertFormErrors(['Enter a valid IPv4 address.'], f.clean, '1.2.3.4.5')
self.assertFormErrors(['Enter a valid IPv4 address.'], f.clean, '256.125.1.5')
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField(required=False)
self.assertEqual(f.clean(''), '')
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
index 4b4a4bc001..3ecf693d70 100644
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -336,20 +336,6 @@ class FormsFormsetTestCase(TestCase):
def test_more_initial_data(self):
# The extra argument also works when the formset is pre-filled with initial
# data.
-
- data = {
- 'choices-TOTAL_FORMS': '3', # the number of forms rendered
- 'choices-INITIAL_FORMS': '0', # the number of forms with initial data
- 'choices-MIN_NUM_FORMS': '0', # min number of forms
- 'choices-MAX_NUM_FORMS': '0', # max number of forms
- 'choices-0-choice': 'Calexico',
- 'choices-0-votes': '100',
- 'choices-1-choice': '',
- 'choices-1-votes': '', # missing value
- 'choices-2-choice': '',
- 'choices-2-votes': '',
- }
-
initial = [{'choice': 'Calexico', 'votes': 100}]
ChoiceFormSet = formset_factory(Choice, extra=3)
formset = ChoiceFormSet(initial=initial, auto_id=False, prefix='choices')
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 159d03ab7e..256036dbad 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -94,9 +94,9 @@ class ModelFormCallableModelDefault(TestCase):
def test_callable_initial_value(self):
"The initial value for a callable default returning a queryset is the pk (refs #13769)"
- obj1 = ChoiceOptionModel.objects.create(id=1, name='default')
- obj2 = ChoiceOptionModel.objects.create(id=2, name='option 2')
- obj3 = ChoiceOptionModel.objects.create(id=3, name='option 3')
+ ChoiceOptionModel.objects.create(id=1, name='default')
+ ChoiceOptionModel.objects.create(id=2, name='option 2')
+ ChoiceOptionModel.objects.create(id=3, name='option 3')
self.assertHTMLEqual(ChoiceFieldForm().as_p(), """<p><label for="id_choice">Choice:</label> <select name="choice" id="id_choice">
<option value="1" selected="selected">ChoiceOption 1</option>
<option value="2">ChoiceOption 2</option>
@@ -120,7 +120,7 @@ class ModelFormCallableModelDefault(TestCase):
def test_initial_instance_value(self):
"Initial instances for model fields may also be instances (refs #7287)"
- obj1 = ChoiceOptionModel.objects.create(id=1, name='default')
+ ChoiceOptionModel.objects.create(id=1, name='default')
obj2 = ChoiceOptionModel.objects.create(id=2, name='option 2')
obj3 = ChoiceOptionModel.objects.create(id=3, name='option 3')
self.assertHTMLEqual(ChoiceFieldForm(initial={