From 11cd7388f77aa9d12ab6b57285c3801b237e241b Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Thu, 29 Aug 2013 19:20:00 -0400 Subject: Fixed #20989 -- Removed useless explicit list comprehensions. --- tests/forms_tests/tests/test_error_messages.py | 2 +- tests/forms_tests/tests/test_extra.py | 2 +- tests/forms_tests/tests/test_forms.py | 6 +++--- tests/forms_tests/tests/test_formsets.py | 2 +- tests/forms_tests/tests/test_widgets.py | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py index f0638298e9..2b1bec1647 100644 --- a/tests/forms_tests/tests/test_error_messages.py +++ b/tests/forms_tests/tests/test_error_messages.py @@ -221,7 +221,7 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin): def as_divs(self): if not self: return '' - return mark_safe('
%s
' % ''.join(['

%s

' % e for e in self])) + return mark_safe('
%s
' % ''.join('

%s

' % e for e in self)) # This form should print errors the default way. form1 = TestForm({'first_name': 'John'}) diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py index b86245ab73..21186682d5 100644 --- a/tests/forms_tests/tests/test_extra.py +++ b/tests/forms_tests/tests/test_extra.py @@ -723,7 +723,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): def as_divs(self): if not self: return '' - return '
%s
' % ''.join(['
%s
' % force_text(e) for e in self]) + return '
%s
' % ''.join('
%s
' % force_text(e) for e in self) class CommentForm(Form): name = CharField(max_length=50, required=False) diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 1c72d17abe..06ee3212a9 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -437,11 +437,11 @@ class FormsTestCase(TestCase): name = ChoiceField(choices=[('john', 'John'), ('paul', 'Paul'), ('george', 'George'), ('ringo', 'Ringo')], widget=RadioSelect) f = BeatleForm(auto_id=False) - self.assertHTMLEqual('\n'.join([str(bf) for bf in f['name']]), """ + self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), """ """) - self.assertHTMLEqual('\n'.join(['
%s
' % bf for bf in f['name']]), """
+ self.assertHTMLEqual('\n'.join('
%s
' % bf for bf in f['name']), """
""") @@ -452,7 +452,7 @@ class FormsTestCase(TestCase): name = CharField() f = BeatleForm(auto_id=False) - self.assertHTMLEqual('\n'.join([str(bf) for bf in f['name']]), '') + self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), '') def test_forms_with_multiple_choice(self): # MultipleChoiceField is a special case, as its data is required to be a list: diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 41577e6049..6372f2a8f4 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -900,7 +900,7 @@ class FormsFormsetTestCase(TestCase): } formset = AnotherChoiceFormSet(data, auto_id=False, prefix='choices') self.assertTrue(formset.is_valid()) - self.assertTrue(all([form.is_valid_called for form in formset.forms])) + self.assertTrue(all(form.is_valid_called for form in formset.forms)) def test_hard_limit_on_instantiated_forms(self): """A formset has a hard limit on the number of forms instantiated.""" diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py index 3f11771d7a..7f23b1a8b5 100644 --- a/tests/forms_tests/tests/test_widgets.py +++ b/tests/forms_tests/tests/test_widgets.py @@ -640,7 +640,7 @@ beatle J R Ringo False""") # You can create your own custom renderers for RadioSelect to use. class MyRenderer(RadioFieldRenderer): def render(self): - return '
\n'.join([six.text_type(choice) for choice in self]) + return '
\n'.join(six.text_type(choice) for choice in self) w = RadioSelect(renderer=MyRenderer) self.assertHTMLEqual(w.render('beatle', 'G', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))), """

@@ -835,17 +835,17 @@ beatle J R Ringo False""") def test_subwidget(self): # Each subwidget tag gets a separate ID when the widget has an ID specified - self.assertHTMLEqual("\n".join([c.tag() for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))]), """ + self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """ """) # Each subwidget tag does not get an ID if the widget does not have an ID specified - self.assertHTMLEqual("\n".join([c.tag() for c in CheckboxSelectMultiple().subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))]), """ + self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple().subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """ """) # The id_for_label property of the subwidget should return the ID that is used on the subwidget's tag - self.assertHTMLEqual("\n".join(['' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))]), """ + self.assertHTMLEqual("\n".join('' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))), """ """) -- cgit v1.3