diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-26 12:15:03 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-26 12:15:03 -0700 |
| commit | 9d740eb8b15de31f1c5520659df683d90342bb44 (patch) | |
| tree | 62b6ff49e5a60467828f9b04d46b6ebeac86c333 /tests/forms_tests | |
| parent | f2d8027c9aea93750fc4213d9e733c8575e89502 (diff) | |
Fix all violators of E231
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_extra.py | 36 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_fields.py | 10 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 12 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_formsets.py | 10 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_input_formats.py | 150 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_media.py | 172 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_widgets.py | 17 | ||||
| -rw-r--r-- | tests/forms_tests/tests/tests.py | 2 |
8 files changed, 204 insertions, 205 deletions
diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py index 333e8cfb41..183b5dabdf 100644 --- a/tests/forms_tests/tests/test_extra.py +++ b/tests/forms_tests/tests/test_extra.py @@ -38,7 +38,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): # The forms library comes with some extra, higher-level Field and Widget def test_selectdate(self): - w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016')) + w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016')) # Rendering the default state. self.assertHTMLEqual(w.render('mydate', ''), """<select name="mydate_month" id="id_mydate_month"> @@ -293,7 +293,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): </select>""") # Using a SelectDateWidget in a form. - w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'), required=False) + w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'), required=False) self.assertHTMLEqual(w.render('mydate', ''), """<select name="mydate_month" id="id_mydate_month"> <option value="0">---</option> <option value="1">January</option> @@ -419,7 +419,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): <option value="2016">2016</option> </select>""") - a = GetDate({'mydate_month':'4', 'mydate_day':'1', 'mydate_year':'2008'}) + a = GetDate({'mydate_month': '4', 'mydate_day': '1', 'mydate_year': '2008'}) self.assertTrue(a.is_valid()) self.assertEqual(a.cleaned_data['mydate'], datetime.date(2008, 4, 1)) @@ -429,17 +429,17 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): self.assertHTMLEqual(a['mydate'].as_hidden(), '<input type="hidden" name="mydate" value="2008-4-1" id="id_mydate" />') - b = GetDate({'mydate':'2008-4-1'}) + b = GetDate({'mydate': '2008-4-1'}) self.assertTrue(b.is_valid()) self.assertEqual(b.cleaned_data['mydate'], datetime.date(2008, 4, 1)) # Invalid dates shouldn't be allowed - c = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'}) + c = GetDate({'mydate_month': '2', 'mydate_day': '31', 'mydate_year': '2010'}) self.assertFalse(c.is_valid()) self.assertEqual(c.errors, {'mydate': ['Enter a valid date.']}) # label tag is correctly associated with month dropdown - d = GetDate({'mydate_month':'1', 'mydate_day':'1', 'mydate_year':'2010'}) + d = GetDate({'mydate_month': '1', 'mydate_day': '1', 'mydate_year': '2010'}) self.assertTrue('<label for="id_mydate_month">' in d.as_p()) def test_multiwidget(self): @@ -488,31 +488,31 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): def compress(self, data_list): if data_list: - return '%s,%s,%s' % (data_list[0],''.join(data_list[1]),data_list[2]) + return '%s,%s,%s' % (data_list[0], ''.join(data_list[1]), data_list[2]) return None f = ComplexField(widget=w) - self.assertEqual(f.clean(['some text', ['J','P'], ['2007-04-25','6:24:00']]), 'some text,JP,2007-04-25 06:24:00') - self.assertFormErrors(['Select a valid choice. X is not one of the available choices.'], f.clean, ['some text',['X'], ['2007-04-25','6:24:00']]) + self.assertEqual(f.clean(['some text', ['J', 'P'], ['2007-04-25', '6:24:00']]), 'some text,JP,2007-04-25 06:24:00') + self.assertFormErrors(['Select a valid choice. X is not one of the available choices.'], f.clean, ['some text', ['X'], ['2007-04-25', '6:24:00']]) # If insufficient data is provided, None is substituted - self.assertFormErrors(['This field is required.'], f.clean, ['some text',['JP']]) + self.assertFormErrors(['This field is required.'], f.clean, ['some text', ['JP']]) # test with no initial data - self.assertTrue(f._has_changed(None, ['some text', ['J','P'], ['2007-04-25','6:24:00']])) + self.assertTrue(f._has_changed(None, ['some text', ['J', 'P'], ['2007-04-25', '6:24:00']])) # test when the data is the same as initial self.assertFalse(f._has_changed('some text,JP,2007-04-25 06:24:00', - ['some text', ['J','P'], ['2007-04-25','6:24:00']])) + ['some text', ['J', 'P'], ['2007-04-25', '6:24:00']])) # test when the first widget's data has changed self.assertTrue(f._has_changed('some text,JP,2007-04-25 06:24:00', - ['other text', ['J','P'], ['2007-04-25','6:24:00']])) + ['other text', ['J', 'P'], ['2007-04-25', '6:24:00']])) # test when the last widget's data has changed. this ensures that it is not # short circuiting while testing the widgets. self.assertTrue(f._has_changed('some text,JP,2007-04-25 06:24:00', - ['some text', ['J','P'], ['2009-04-25','11:44:00']])) + ['some text', ['J', 'P'], ['2009-04-25', '11:44:00']])) class ComplexFieldForm(Form): field1 = ComplexField(widget=w) @@ -527,7 +527,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): </select> <input type="text" name="field1_2_0" id="id_field1_2_0" /><input type="text" name="field1_2_1" id="id_field1_2_1" /></td></tr>""") - f = ComplexFieldForm({'field1_0':'some text','field1_1':['J','P'], 'field1_2_0':'2007-04-25', 'field1_2_1':'06:24:00'}) + f = ComplexFieldForm({'field1_0': 'some text', 'field1_1': ['J', 'P'], 'field1_2_0': '2007-04-25', 'field1_2_1': '06:24:00'}) self.assertHTMLEqual(f.as_table(), """<tr><th><label for="id_field1_0">Field1:</label></th><td><input type="text" name="field1_0" value="some text" id="id_field1_0" /> <select multiple="multiple" name="field1_1" id="id_field1_1"> <option value="J" selected="selected">John</option> @@ -785,7 +785,7 @@ class FormsExtraL10NTestCase(TestCase): super(FormsExtraL10NTestCase, self).tearDown() def test_l10n(self): - w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'), required=False) + w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'), required=False) self.assertEqual(w.value_from_datadict({'date_year': '2010', 'date_month': '8', 'date_day': '13'}, {}, 'date'), '13-08-2010') self.assertHTMLEqual(w.render('date', '13-08-2010'), """<select name="date_day" id="id_date_day"> @@ -911,12 +911,12 @@ class FormsExtraL10NTestCase(TestCase): def test_l10n_invalid_date_in(self): # Invalid dates shouldn't be allowed - a = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'}) + a = GetDate({'mydate_month': '2', 'mydate_day': '31', 'mydate_year': '2010'}) self.assertFalse(a.is_valid()) # 'Geef een geldige datum op.' = 'Enter a valid date.' self.assertEqual(a.errors, {'mydate': ['Geef een geldige datum op.']}) def test_form_label_association(self): # label tag is correctly associated with first rendered dropdown - a = GetDate({'mydate_month':'1', 'mydate_day':'1', 'mydate_year':'2010'}) + a = GetDate({'mydate_month': '1', 'mydate_day': '1', 'mydate_year': '2010'}) self.assertTrue('<label for="id_mydate_day">' in a.as_p()) diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index 596ab54285..e7412b81d7 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -905,7 +905,7 @@ class FieldsTests(SimpleTestCase): self.assertRaisesMessage(ValidationError, "'Select a valid choice. John is not one of the available choices.'", f.clean, 'John') def test_choicefield_4(self): - f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')]) + f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3', 'A'), ('4', 'B'))), ('5', 'Other')]) self.assertEqual('1', f.clean(1)) self.assertEqual('1', f.clean('1')) self.assertEqual('3', f.clean(3)) @@ -1043,7 +1043,7 @@ class FieldsTests(SimpleTestCase): self.assertRaisesMessage(ValidationError, "'Select a valid choice. 3 is not one of the available choices.'", f.clean, ['3']) def test_multiplechoicefield_3(self): - f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')]) + f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3', 'A'), ('4', 'B'))), ('5', 'Other')]) self.assertEqual(['1'], f.clean([1])) self.assertEqual(['1'], f.clean(['1'])) self.assertEqual(['1', '5'], f.clean([1, 5])) @@ -1051,7 +1051,7 @@ class FieldsTests(SimpleTestCase): self.assertEqual(['1', '5'], f.clean(['1', 5])) self.assertEqual(['1', '5'], f.clean(['1', '5'])) self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['6']) - self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['1','6']) + self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['1', '6']) def test_multiplechoicefield_changed(self): f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two'), ('3', 'Three')]) @@ -1084,8 +1084,8 @@ class FieldsTests(SimpleTestCase): def test_typedmultiplechoicefield_4(self): f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int) - self.assertEqual([1, -1], f.clean(['1','-1'])) - self.assertRaisesMessage(ValidationError, "'Select a valid choice. 2 is not one of the available choices.'", f.clean, ['1','2']) + self.assertEqual([1, -1], f.clean(['1', '-1'])) + self.assertRaisesMessage(ValidationError, "'Select a valid choice. 2 is not one of the available choices.'", f.clean, ['1', '2']) def test_typedmultiplechoicefield_5(self): # Even more weirdness: if you have a valid choice but your coercion function diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 32ede445b7..0f1b8882f3 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -1124,7 +1124,7 @@ class FormsTestCase(TestCase): class UserRegistration(Form): username = CharField(max_length=10) password = CharField(widget=PasswordInput) - options = MultipleChoiceField(choices=[('f','foo'),('b','bar'),('w','whiz')]) + options = MultipleChoiceField(choices=[('f', 'foo'), ('b', 'bar'), ('w', 'whiz')]) # We need to define functions that get called later.) def initial_django(): @@ -1134,10 +1134,10 @@ class FormsTestCase(TestCase): return 'stephane' def initial_options(): - return ['f','b'] + return ['f', 'b'] def initial_other_options(): - return ['b','w'] + return ['b', 'w'] # Here, we're not submitting any data, so the initial value will be displayed.) p = UserRegistration(initial={'username': initial_django, 'options': initial_options}, auto_id=False) @@ -1166,7 +1166,7 @@ class FormsTestCase(TestCase): <option value="b">bar</option> <option value="w">whiz</option> </select></li>""") - p = UserRegistration({'username': 'foo', 'options':['f','b']}, initial={'username': initial_django}, auto_id=False) + p = UserRegistration({'username': 'foo', 'options': ['f', 'b']}, initial={'username': initial_django}, auto_id=False) self.assertHTMLEqual(p.as_ul(), """<li>Username: <input type="text" name="username" value="foo" maxlength="10" /></li> <li><ul class="errorlist"><li>This field is required.</li></ul>Password: <input type="password" name="password" /></li> <li>Options: <select multiple="multiple" name="options"> @@ -1187,7 +1187,7 @@ class FormsTestCase(TestCase): class UserRegistration(Form): username = CharField(max_length=10, initial=initial_django) password = CharField(widget=PasswordInput) - options = MultipleChoiceField(choices=[('f','foo'),('b','bar'),('w','whiz')], initial=initial_other_options) + options = MultipleChoiceField(choices=[('f', 'foo'), ('b', 'bar'), ('w', 'whiz')], initial=initial_other_options) p = UserRegistration(auto_id=False) self.assertHTMLEqual(p.as_ul(), """<li>Username: <input type="text" name="username" value="django" maxlength="10" /></li> @@ -1813,7 +1813,7 @@ class FormsTestCase(TestCase): class ChoicesField(MultiValueField): def __init__(self, fields=(), *args, **kwargs): fields = (ChoiceField(label='Rank', - choices=((1,1),(2,2))), + choices=((1, 1), (2, 2))), CharField(label='Name', max_length=10)) super(ChoicesField, self).__init__(fields=fields, *args, **kwargs) diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 3ecf693d70..784724bf41 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -1106,19 +1106,19 @@ ChoiceFormSet = formset_factory(Choice) class FormsetAsFooTests(TestCase): def test_as_table(self): formset = ChoiceFormSet(data, auto_id=False, prefix='choices') - self.assertHTMLEqual(formset.as_table(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> + self.assertHTMLEqual(formset.as_table(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> <tr><th>Choice:</th><td><input type="text" name="choices-0-choice" value="Calexico" /></td></tr> <tr><th>Votes:</th><td><input type="number" name="choices-0-votes" value="100" /></td></tr>""") def test_as_p(self): formset = ChoiceFormSet(data, auto_id=False, prefix='choices') - self.assertHTMLEqual(formset.as_p(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> + self.assertHTMLEqual(formset.as_p(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> <p>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></p> <p>Votes: <input type="number" name="choices-0-votes" value="100" /></p>""") def test_as_ul(self): formset = ChoiceFormSet(data, auto_id=False, prefix='choices') - self.assertHTMLEqual(formset.as_ul(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> + self.assertHTMLEqual(formset.as_ul(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" /> <li>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></li> <li>Votes: <input type="number" name="choices-0-votes" value="100" /></li>""") @@ -1188,8 +1188,8 @@ class TestEmptyFormSet(TestCase): def test_empty_formset_is_valid(self): """Test that an empty formset still calls clean()""" EmptyFsetWontValidateFormset = formset_factory(FavoriteDrinkForm, extra=0, formset=EmptyFsetWontValidate) - formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'0'},prefix="form") - formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah'},prefix="form") + formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS': '0', 'form-TOTAL_FORMS': '0'}, prefix="form") + formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS': '0', 'form-TOTAL_FORMS': '1', 'form-0-name': 'bah'}, prefix="form") self.assertFalse(formset.is_valid()) self.assertFalse(formset2.is_valid()) diff --git a/tests/forms_tests/tests/test_input_formats.py b/tests/forms_tests/tests/test_input_formats.py index eb0e8dcad8..95308d4eeb 100644 --- a/tests/forms_tests/tests/test_input_formats.py +++ b/tests/forms_tests/tests/test_input_formats.py @@ -24,7 +24,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30:05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -32,7 +32,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid, but non-default format, get a parsed result result = f.clean('13:30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -40,7 +40,7 @@ class LocalizedTimeTests(SimpleTestCase): # ISO formats are accepted, even if not specified in formats.py result = f.clean('13:30:05.000155') - self.assertEqual(result, time(13,30,5,155)) + self.assertEqual(result, time(13, 30, 5, 155)) def test_localized_timeField(self): "Localized TimeFields act as unlocalized widgets" @@ -50,7 +50,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30:05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -58,7 +58,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -73,7 +73,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30.05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -81,7 +81,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -96,7 +96,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30.05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -104,7 +104,7 @@ class LocalizedTimeTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -121,7 +121,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30:05 PM') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -129,7 +129,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid, but non-default format, get a parsed result result = f.clean('1:30 PM') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -143,7 +143,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30:05 PM') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -151,7 +151,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('01:30 PM') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -166,7 +166,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30.05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -174,7 +174,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -189,7 +189,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30.05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -197,7 +197,7 @@ class CustomTimeInputFormatsTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13.30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -213,7 +213,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30:05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -221,7 +221,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid, but non-default format, get a parsed result result = f.clean('13:30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -235,7 +235,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30:05') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -243,7 +243,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('13:30') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -257,7 +257,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30:05 PM') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -265,7 +265,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30 PM') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -279,7 +279,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30:05 PM') - self.assertEqual(result, time(13,30,5)) + self.assertEqual(result, time(13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -287,7 +287,7 @@ class SimpleTimeFormatTests(SimpleTestCase): # Parse a time in a valid format, get a parsed result result = f.clean('1:30 PM') - self.assertEqual(result, time(13,30,0)) + self.assertEqual(result, time(13, 30, 0)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -309,11 +309,11 @@ class LocalizedDateTests(SimpleTestCase): self.assertRaises(forms.ValidationError, f.clean, '21/12/2010') # ISO formats are accepted, even if not specified in formats.py - self.assertEqual(f.clean('2010-12-21'), date(2010,12,21)) + self.assertEqual(f.clean('2010-12-21'), date(2010, 12, 21)) # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -321,7 +321,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('21.12.10') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -335,7 +335,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -343,7 +343,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.10') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -359,7 +359,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -367,7 +367,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -383,7 +383,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -391,7 +391,7 @@ class LocalizedDateTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -408,7 +408,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -416,7 +416,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('21-12-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -430,7 +430,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -438,7 +438,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21-12-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -453,7 +453,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -461,7 +461,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -476,7 +476,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -484,7 +484,7 @@ class CustomDateInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -499,7 +499,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('2010-12-21') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -507,7 +507,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('12/21/2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -521,7 +521,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('2010-12-21') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -529,7 +529,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12/21/2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -543,7 +543,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -551,7 +551,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21-12-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -565,7 +565,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -573,7 +573,7 @@ class SimpleDateFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21-12-2010') - self.assertEqual(result, date(2010,12,21)) + self.assertEqual(result, date(2010, 12, 21)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -595,11 +595,11 @@ class LocalizedDateTimeTests(SimpleTestCase): self.assertRaises(forms.ValidationError, f.clean, '1:30:05 PM 21/12/2010') # ISO formats are accepted, even if not specified in formats.py - self.assertEqual(f.clean('2010-12-21 13:30:05'), datetime(2010,12,21,13,30,5)) + self.assertEqual(f.clean('2010-12-21 13:30:05'), datetime(2010, 12, 21, 13, 30, 5)) # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -607,7 +607,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('21.12.2010 13:30') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -621,7 +621,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -629,7 +629,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('21.12.2010 13:30') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -645,7 +645,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('13.30.05 12.21.2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -653,7 +653,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('13.30 12-21-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -669,7 +669,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('13.30.05 12.21.2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -677,7 +677,7 @@ class LocalizedDateTimeTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('13.30 12-21-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -694,7 +694,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30:05 PM 21/12/2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip text = f.widget._format_value(result) @@ -702,7 +702,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('1:30 PM 21-12-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -716,7 +716,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30:05 PM 21/12/2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -724,7 +724,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30 PM 21-12-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -739,7 +739,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -747,7 +747,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010 13:30') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -762,7 +762,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12.21.2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -770,7 +770,7 @@ class CustomDateTimeInputFormatsTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12-21-2010 13:30') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -785,7 +785,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('2010-12-21 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -793,7 +793,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid, but non-default format, get a parsed result result = f.clean('12/21/2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -807,7 +807,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('2010-12-21 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -815,7 +815,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('12/21/2010 13:30:05') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -829,7 +829,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30:05 PM 21.12.2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -837,7 +837,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30 PM 21-12-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) @@ -851,7 +851,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30:05 PM 21.12.2010') - self.assertEqual(result, datetime(2010,12,21,13,30,5)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5)) # Check that the parsed result does a round trip to the same format text = f.widget._format_value(result) @@ -859,7 +859,7 @@ class SimpleDateTimeFormatTests(SimpleTestCase): # Parse a date in a valid format, get a parsed result result = f.clean('1:30 PM 21-12-2010') - self.assertEqual(result, datetime(2010,12,21,13,30)) + self.assertEqual(result, datetime(2010, 12, 21, 13, 30)) # Check that the parsed result does a round trip to default format text = f.widget._format_value(result) diff --git a/tests/forms_tests/tests/test_media.py b/tests/forms_tests/tests/test_media.py index 87a4bb7cd6..ab00b44495 100644 --- a/tests/forms_tests/tests/test_media.py +++ b/tests/forms_tests/tests/test_media.py @@ -14,7 +14,7 @@ class FormsMediaTestCase(TestCase): def test_construction(self): # Check construction of media objects - m = Media(css={'all': ('path/to/css1','/path/to/css2')}, js=('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')) + m = Media(css={'all': ('path/to/css1', '/path/to/css2')}, js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')) self.assertEqual(str(m), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> @@ -23,9 +23,9 @@ class FormsMediaTestCase(TestCase): class Foo: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') m3 = Media(Foo) self.assertEqual(str(m3), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -52,9 +52,9 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') w1 = MyWidget1() self.assertEqual(str(w1.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -77,23 +77,23 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w1 = MyWidget1() w2 = MyWidget2() @@ -158,9 +158,9 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget6(MyWidget1): def _media(self): @@ -185,9 +185,9 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget7(MyWidget1): pass @@ -203,9 +203,9 @@ class FormsMediaTestCase(TestCase): class MyWidget8(MyWidget1): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w8 = MyWidget8() self.assertEqual(str(w8.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -222,9 +222,9 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget4(TextInput): def _media(self): @@ -249,9 +249,9 @@ class FormsMediaTestCase(TestCase): class Media: extend = False css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w10 = MyWidget10() self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> @@ -264,17 +264,17 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget11(MyWidget1): class Media: extend = True css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w11 = MyWidget11() self.assertEqual(str(w11.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -290,17 +290,17 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget12(MyWidget1): class Media: extend = ('css',) css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w12 = MyWidget12() self.assertEqual(str(w12.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -318,11 +318,11 @@ class FormsMediaTestCase(TestCase): class MultimediaWidget(TextInput): class Media: css = { - 'screen, print': ('/file1','/file2'), + 'screen, print': ('/file1', '/file2'), 'screen': ('/file3',), 'print': ('/file4',) } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') multimedia = MultimediaWidget() self.assertEqual(str(multimedia.media), """<link href="/file4" type="text/css" media="print" rel="stylesheet" /> @@ -340,23 +340,23 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') # MultiWidgets have a default media definition that gets all the # media from the component widgets @@ -382,23 +382,23 @@ class FormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') # You can ask a form for the media required by its widgets. class MyForm(Form): @@ -466,7 +466,7 @@ class StaticFormsMediaTestCase(TestCase): def test_construction(self): # Check construction of media objects - m = Media(css={'all': ('path/to/css1','/path/to/css2')}, js=('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')) + m = Media(css={'all': ('path/to/css1', '/path/to/css2')}, js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')) self.assertEqual(str(m), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> <link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/path/to/js1"></script> @@ -475,9 +475,9 @@ class StaticFormsMediaTestCase(TestCase): class Foo: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') m3 = Media(Foo) self.assertEqual(str(m3), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -504,9 +504,9 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') w1 = MyWidget1() self.assertEqual(str(w1.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -529,23 +529,23 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w1 = MyWidget1() w2 = MyWidget2() @@ -610,9 +610,9 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget6(MyWidget1): def _media(self): @@ -637,9 +637,9 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget7(MyWidget1): pass @@ -655,9 +655,9 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget8(MyWidget1): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w8 = MyWidget8() self.assertEqual(str(w8.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -674,9 +674,9 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget4(TextInput): def _media(self): @@ -701,9 +701,9 @@ class StaticFormsMediaTestCase(TestCase): class Media: extend = False css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w10 = MyWidget10() self.assertEqual(str(w10.media), """<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" /> @@ -716,17 +716,17 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget11(MyWidget1): class Media: extend = True css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w11 = MyWidget11() self.assertEqual(str(w11.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -742,17 +742,17 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget12(MyWidget1): class Media: extend = ('css',) css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') w12 = MyWidget12() self.assertEqual(str(w12.media), """<link href="http://media.example.com/static/path/to/css1" type="text/css" media="all" rel="stylesheet" /> @@ -770,11 +770,11 @@ class StaticFormsMediaTestCase(TestCase): class MultimediaWidget(TextInput): class Media: css = { - 'screen, print': ('/file1','/file2'), + 'screen, print': ('/file1', '/file2'), 'screen': ('/file3',), 'print': ('/file4',) } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') multimedia = MultimediaWidget() self.assertEqual(str(multimedia.media), """<link href="/file4" type="text/css" media="print" rel="stylesheet" /> @@ -792,23 +792,23 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') # MultiWidgets have a default media definition that gets all the # media from the component widgets @@ -834,23 +834,23 @@ class StaticFormsMediaTestCase(TestCase): class MyWidget1(TextInput): class Media: css = { - 'all': ('path/to/css1','/path/to/css2') + 'all': ('path/to/css1', '/path/to/css2') } - js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3') + js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3') class MyWidget2(TextInput): class Media: css = { - 'all': ('/path/to/css2','/path/to/css3') + 'all': ('/path/to/css2', '/path/to/css3') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') class MyWidget3(TextInput): class Media: css = { - 'all': ('/path/to/css3','path/to/css1') + 'all': ('/path/to/css3', 'path/to/css1') } - js = ('/path/to/js1','/path/to/js4') + js = ('/path/to/js1', '/path/to/js4') # You can ask a form for the media required by its widgets. class MyForm(Form): diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py index b30f6546d5..c601a3ad58 100644 --- a/tests/forms_tests/tests/test_widgets.py +++ b/tests/forms_tests/tests/test_widgets.py @@ -15,7 +15,6 @@ from django.forms import ( Textarea, TextInput, TimeInput, ) from django.forms.widgets import RadioFieldRenderer -from django.utils import formats from django.utils.safestring import mark_safe from django.utils import six from django.utils.translation import activate, deactivate, override @@ -691,7 +690,7 @@ beatle J R Ringo False""") self.assertHTMLEqual(six.text_type(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')])), '<ul>\n<li><label><input checked="checked" type="radio" name="email" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" /> \u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</label></li>\n<li><label><input type="radio" name="email" value="\u0107\u017e\u0161\u0111" /> abc\u0107\u017e\u0161\u0111</label></li>\n</ul>') # Attributes provided at instantiation are passed to the constituent inputs - w = RadioSelect(attrs={'id':'foo'}) + w = RadioSelect(attrs={'id': 'foo'}) self.assertHTMLEqual(w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))), """<ul id="foo"> <li><label for="foo_0"><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li> <li><label for="foo_1"><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li> @@ -701,7 +700,7 @@ beatle J R Ringo False""") # Attributes provided at render-time are passed to the constituent inputs w = RadioSelect() - self.assertHTMLEqual(w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id':'bar'}), """<ul id="bar"> + self.assertHTMLEqual(w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id': 'bar'}), """<ul id="bar"> <li><label for="bar_0"><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li> <li><label for="bar_1"><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li> <li><label for="bar_2"><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li> @@ -716,7 +715,7 @@ beatle J R Ringo False""") ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), ('Video', (('vhs', 'VHS'), ('dvd', 'DVD'))), ) - self.assertHTMLEqual(w.render('nestchoice', 'dvd', attrs={'id':'media'}), """<ul id="media"> + self.assertHTMLEqual(w.render('nestchoice', 'dvd', attrs={'id': 'media'}), """<ul id="media"> <li><label for="media_0"><input id="media_0" name="nestchoice" type="radio" value="unknown" /> Unknown</label></li> <li>Audio<ul id="media_1"> <li><label for="media_1_0"><input id="media_1_0" name="nestchoice" type="radio" value="vinyl" /> Vinyl</label></li> @@ -735,7 +734,7 @@ beatle J R Ringo False""") ('Audio', (('vinyl', 'Vinyl'), ('cd', 'CD'))), ('Video', (('vhs', 'VHS'), ('dvd', 'DVD'))), ) - self.assertHTMLEqual(w.render('nestchoice', ('vinyl', 'dvd'), attrs={'id':'media'}), """<ul id="media"> + self.assertHTMLEqual(w.render('nestchoice', ('vinyl', 'dvd'), attrs={'id': 'media'}), """<ul id="media"> <li><label for="media_0"><input id="media_0" name="nestchoice" type="checkbox" value="unknown" /> Unknown</label></li> <li>Audio<ul id="media_1"> <li><label for="media_1_0"><input checked="checked" id="media_1_0" name="nestchoice" type="checkbox" value="vinyl" /> Vinyl</label></li> @@ -912,7 +911,7 @@ beatle J R Ringo False""") w = MyMultiWidget(widgets=(TextInput(attrs={'class': 'big'}), TextInput(attrs={'class': 'small'}))) self.assertHTMLEqual(w.render('name', ['john', 'lennon']), '<input type="text" class="big" value="john" name="name_0" /><br /><input type="text" class="small" value="lennon" name="name_1" />') self.assertHTMLEqual(w.render('name', 'john__lennon'), '<input type="text" class="big" value="john" name="name_0" /><br /><input type="text" class="small" value="lennon" name="name_1" />') - self.assertHTMLEqual(w.render('name', 'john__lennon', attrs={'id':'foo'}), '<input id="foo_0" type="text" class="big" value="john" name="name_0" /><br /><input id="foo_1" type="text" class="small" value="lennon" name="name_1" />') + self.assertHTMLEqual(w.render('name', 'john__lennon', attrs={'id': 'foo'}), '<input id="foo_0" type="text" class="big" value="john" name="name_0" /><br /><input id="foo_1" type="text" class="small" value="lennon" name="name_1" />') w = MyMultiWidget(widgets=(TextInput(attrs={'class': 'big'}), TextInput(attrs={'class': 'small'})), attrs={'id': 'bar'}) self.assertHTMLEqual(w.render('name', ['john', 'lennon']), '<input id="bar_0" type="text" class="big" value="john" name="name_0" /><br /><input id="bar_1" type="text" class="small" value="lennon" name="name_1" />') @@ -1081,12 +1080,12 @@ class SelectAndTextWidget(MultiWidget): class WidgetTests(TestCase): def test_12048(self): # See ticket #12048. - w1 = SelectAndTextWidget(choices=[1,2,3]) + w1 = SelectAndTextWidget(choices=[1, 2, 3]) w2 = copy.deepcopy(w1) - w2.choices = [4,5,6] + w2.choices = [4, 5, 6] # w2 ought to be independent of w1, since MultiWidget ought # to make a copy of its sub-widgets when it is copied. - self.assertEqual(w1.choices, [1,2,3]) + self.assertEqual(w1.choices, [1, 2, 3]) def test_13390(self): # See ticket #13390 diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index 361f2dc866..8212d4ee5c 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -126,7 +126,7 @@ class ModelFormCallableModelDefault(TestCase): self.assertHTMLEqual(ChoiceFieldForm(initial={ 'choice': obj2, 'choice_int': obj2, - 'multi_choice': [obj2,obj3], + 'multi_choice': [obj2, obj3], 'multi_choice_int': ChoiceOptionModel.objects.exclude(name="default"), }).as_p(), """<p><label for="id_choice">Choice:</label> <select name="choice" id="id_choice"> <option value="1">ChoiceOption 1</option> |
