diff options
| author | Simon Charette <charette.s@gmail.com> | 2013-08-29 19:20:00 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2013-08-30 10:57:51 -0400 |
| commit | 11cd7388f77aa9d12ab6b57285c3801b237e241b (patch) | |
| tree | e4853e5c87e1de082660e10b2144b91b4d9b7d0c /tests | |
| parent | e4a67fd90626ced92a61f38ef682d2aa4f34a3ff (diff) | |
Fixed #20989 -- Removed useless explicit list comprehensions.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/tests.py | 2 | ||||
| -rw-r--r-- | tests/file_uploads/views.py | 4 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_error_messages.py | 2 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_extra.py | 2 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 6 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_formsets.py | 2 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_widgets.py | 8 | ||||
| -rw-r--r-- | tests/proxy_models/tests.py | 2 | ||||
| -rw-r--r-- | tests/schema/tests.py | 4 | ||||
| -rw-r--r-- | tests/servers/views.py | 4 | ||||
| -rw-r--r-- | tests/syndication/tests.py | 2 | ||||
| -rw-r--r-- | tests/template_tests/templatetags/custom.py | 28 | ||||
| -rw-r--r-- | tests/template_tests/tests.py | 2 |
13 files changed, 34 insertions, 34 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py index d6e3f5c78e..64f90996d2 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -79,7 +79,7 @@ class OracleChecks(unittest.TestCase): # than 4000 chars and read it properly c = connection.cursor() c.execute('CREATE TABLE ltext ("TEXT" NCLOB)') - long_str = ''.join([six.text_type(x) for x in xrange(4000)]) + long_str = ''.join(six.text_type(x) for x in xrange(4000)) c.execute('INSERT INTO ltext VALUES (%s)', [long_str]) c.execute('SELECT text FROM ltext') row = c.fetchone() diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py index 8d20a9cb6e..1940987815 100644 --- a/tests/file_uploads/views.py +++ b/tests/file_uploads/views.py @@ -89,14 +89,14 @@ def file_upload_echo(request): """ Simple view to echo back info about uploaded files for tests. """ - r = dict([(k, f.name) for k, f in request.FILES.items()]) + r = dict((k, f.name) for k, f in request.FILES.items()) return HttpResponse(json.dumps(r)) def file_upload_echo_content(request): """ Simple view to echo back the content of uploaded files for tests. """ - r = dict([(k, f.read().decode('utf-8')) for k, f in request.FILES.items()]) + r = dict((k, f.read().decode('utf-8')) for k, f in request.FILES.items()) return HttpResponse(json.dumps(r)) def file_upload_quota(request): 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('<div class="error">%s</div>' % ''.join(['<p>%s</p>' % e for e in self])) + return mark_safe('<div class="error">%s</div>' % ''.join('<p>%s</p>' % 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 '<div class="errorlist">%s</div>' % ''.join(['<div class="error">%s</div>' % force_text(e) for e in self]) + return '<div class="errorlist">%s</div>' % ''.join('<div class="error">%s</div>' % 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']]), """<label><input type="radio" name="name" value="john" /> John</label> + self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), """<label><input type="radio" name="name" value="john" /> John</label> <label><input type="radio" name="name" value="paul" /> Paul</label> <label><input type="radio" name="name" value="george" /> George</label> <label><input type="radio" name="name" value="ringo" /> Ringo</label>""") - self.assertHTMLEqual('\n'.join(['<div>%s</div>' % bf for bf in f['name']]), """<div><label><input type="radio" name="name" value="john" /> John</label></div> + self.assertHTMLEqual('\n'.join('<div>%s</div>' % bf for bf in f['name']), """<div><label><input type="radio" name="name" value="john" /> John</label></div> <div><label><input type="radio" name="name" value="paul" /> Paul</label></div> <div><label><input type="radio" name="name" value="george" /> George</label></div> <div><label><input type="radio" name="name" value="ringo" /> Ringo</label></div>""") @@ -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']]), '<input type="text" name="name" />') + self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), '<input type="text" name="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 '<br />\n'.join([six.text_type(choice) for choice in self]) + return '<br />\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'))), """<label><input type="radio" name="beatle" value="J" /> John</label><br /> <label><input type="radio" name="beatle" value="P" /> Paul</label><br /> @@ -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')))]), """<input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" /> + self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """<input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" /> <input type="checkbox" name="letters" value="b" id="abc_1" /> <input checked="checked" type="checkbox" name="letters" value="c" id="abc_2" />""") # 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')))]), """<input checked="checked" type="checkbox" name="letters" value="a" /> + self.assertHTMLEqual("\n".join(c.tag() for c in CheckboxSelectMultiple().subwidgets('letters', list('ac'), choices=zip(list('abc'), list('ABC')))), """<input checked="checked" type="checkbox" name="letters" value="a" /> <input type="checkbox" name="letters" value="b" /> <input checked="checked" type="checkbox" name="letters" value="c" />""") # The id_for_label property of the subwidget should return the ID that is used on the subwidget's tag - self.assertHTMLEqual("\n".join(['<input type="checkbox" name="letters" value="%s" id="%s" />' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))]), """<input type="checkbox" name="letters" value="a" id="abc_0" /> + self.assertHTMLEqual("\n".join('<input type="checkbox" name="letters" value="%s" id="%s" />' % (c.choice_value, c.id_for_label) for c in CheckboxSelectMultiple(attrs={'id': 'abc'}).subwidgets('letters', [], choices=zip(list('abc'), list('ABC')))), """<input type="checkbox" name="letters" value="a" id="abc_0" /> <input type="checkbox" name="letters" value="b" id="abc_1" /> <input type="checkbox" name="letters" value="c" id="abc_2" />""") diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index f0c0d046e1..f9cb132225 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -79,7 +79,7 @@ class ProxyModelTests(TestCase): Person.objects.create(name="Foo McBar") MyPerson.objects.create(name="Bazza del Frob") LowerStatusPerson.objects.create(status="low", name="homer") - pp = sorted([mpp.name for mpp in MyPersonProxy.objects.all()]) + pp = sorted(mpp.name for mpp in MyPersonProxy.objects.all()) self.assertEqual(pp, ['Bazza del Frob', 'Foo McBar', 'homer']) def test_proxy_included_in_ancestors(self): diff --git a/tests/schema/tests.py b/tests/schema/tests.py index c3764979d6..7c21b58e6c 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -42,7 +42,7 @@ class SchemaTests(TransactionTestCase): "table": connection.ops.quote_name(field.rel.through._meta.db_table), }) except DatabaseError as e: - if any([s in str(e).lower() for s in self.no_table_strings]): + if any(s in str(e).lower() for s in self.no_table_strings): pass else: raise @@ -53,7 +53,7 @@ class SchemaTests(TransactionTestCase): "table": connection.ops.quote_name(model._meta.db_table), }) except DatabaseError as e: - if any([s in str(e).lower() for s in self.no_table_strings]): + if any(s in str(e).lower() for s in self.no_table_strings): pass else: raise diff --git a/tests/servers/views.py b/tests/servers/views.py index 00baf4b5ac..eb7c6c650d 100644 --- a/tests/servers/views.py +++ b/tests/servers/views.py @@ -8,7 +8,7 @@ def example_view(request): def model_view(request): people = Person.objects.all() - return HttpResponse('\n'.join([person.name for person in people])) + return HttpResponse('\n'.join(person.name for person in people)) def create_model_instance(request): @@ -18,4 +18,4 @@ def create_model_instance(request): def environ_view(request): - return HttpResponse("\n".join(["%s: %r" % (k, v) for k, v in request.environ.items()])) + return HttpResponse("\n".join("%s: %r" % (k, v) for k, v in request.environ.items())) diff --git a/tests/syndication/tests.py b/tests/syndication/tests.py index 8bc6b04939..79004aa8b9 100644 --- a/tests/syndication/tests.py +++ b/tests/syndication/tests.py @@ -15,7 +15,7 @@ class FeedTestCase(TestCase): fixtures = ['feeddata.json'] def assertChildNodes(self, elem, expected): - actual = set([n.nodeName for n in elem.childNodes]) + actual = set(n.nodeName for n in elem.childNodes) expected = set(expected) self.assertEqual(actual, expected) diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py index 32035ab59e..5e96ca8eb7 100644 --- a/tests/template_tests/templatetags/custom.py +++ b/tests/template_tests/templatetags/custom.py @@ -64,13 +64,13 @@ simple_one_default.anything = "Expected simple_one_default __dict__" @register.simple_tag def simple_unlimited_args(one, two='hi', *args): """Expected simple_unlimited_args __doc__""" - return "simple_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)])) + return "simple_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args))) simple_unlimited_args.anything = "Expected simple_unlimited_args __dict__" @register.simple_tag def simple_only_unlimited_args(*args): """Expected simple_only_unlimited_args __doc__""" - return "simple_only_unlimited_args - Expected result: %s" % ', '.join([six.text_type(arg) for arg in args]) + return "simple_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args) simple_only_unlimited_args.anything = "Expected simple_only_unlimited_args __dict__" @register.simple_tag @@ -79,8 +79,8 @@ def simple_unlimited_args_kwargs(one, two='hi', *args, **kwargs): # Sort the dictionary by key to guarantee the order for testing. sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0)) return "simple_unlimited_args_kwargs - Expected result: %s / %s" % ( - ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]), - ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg]) + ', '.join(six.text_type(arg) for arg in [one, two] + list(args)), + ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg) ) simple_unlimited_args_kwargs.anything = "Expected simple_unlimited_args_kwargs __dict__" @@ -191,25 +191,25 @@ inclusion_one_default_from_template.anything = "Expected inclusion_one_default_f @register.inclusion_tag('inclusion.html') def inclusion_unlimited_args(one, two='hi', *args): """Expected inclusion_unlimited_args __doc__""" - return {"result": "inclusion_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))} + return {"result": "inclusion_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))} inclusion_unlimited_args.anything = "Expected inclusion_unlimited_args __dict__" @register.inclusion_tag(get_template('inclusion.html')) def inclusion_unlimited_args_from_template(one, two='hi', *args): """Expected inclusion_unlimited_args_from_template __doc__""" - return {"result": "inclusion_unlimited_args_from_template - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)]))} + return {"result": "inclusion_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))} inclusion_unlimited_args_from_template.anything = "Expected inclusion_unlimited_args_from_template __dict__" @register.inclusion_tag('inclusion.html') def inclusion_only_unlimited_args(*args): """Expected inclusion_only_unlimited_args __doc__""" - return {"result": "inclusion_only_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in args]))} + return {"result": "inclusion_only_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))} inclusion_only_unlimited_args.anything = "Expected inclusion_only_unlimited_args __dict__" @register.inclusion_tag(get_template('inclusion.html')) def inclusion_only_unlimited_args_from_template(*args): """Expected inclusion_only_unlimited_args_from_template __doc__""" - return {"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (', '.join([six.text_type(arg) for arg in args]))} + return {"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))} inclusion_only_unlimited_args_from_template.anything = "Expected inclusion_only_unlimited_args_from_template __dict__" @register.inclusion_tag('test_incl_tag_current_app.html', takes_context=True) @@ -230,8 +230,8 @@ def inclusion_unlimited_args_kwargs(one, two='hi', *args, **kwargs): # Sort the dictionary by key to guarantee the order for testing. sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0)) return {"result": "inclusion_unlimited_args_kwargs - Expected result: %s / %s" % ( - ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]), - ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg]) + ', '.join(six.text_type(arg) for arg in [one, two] + list(args)), + ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg) )} inclusion_unlimited_args_kwargs.anything = "Expected inclusion_unlimited_args_kwargs __dict__" @@ -286,13 +286,13 @@ assignment_one_default.anything = "Expected assignment_one_default __dict__" @register.assignment_tag def assignment_unlimited_args(one, two='hi', *args): """Expected assignment_unlimited_args __doc__""" - return "assignment_unlimited_args - Expected result: %s" % (', '.join([six.text_type(arg) for arg in [one, two] + list(args)])) + return "assignment_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args))) assignment_unlimited_args.anything = "Expected assignment_unlimited_args __dict__" @register.assignment_tag def assignment_only_unlimited_args(*args): """Expected assignment_only_unlimited_args __doc__""" - return "assignment_only_unlimited_args - Expected result: %s" % ', '.join([six.text_type(arg) for arg in args]) + return "assignment_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args) assignment_only_unlimited_args.anything = "Expected assignment_only_unlimited_args __dict__" @register.assignment_tag @@ -301,8 +301,8 @@ def assignment_unlimited_args_kwargs(one, two='hi', *args, **kwargs): # Sort the dictionary by key to guarantee the order for testing. sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0)) return "assignment_unlimited_args_kwargs - Expected result: %s / %s" % ( - ', '.join([six.text_type(arg) for arg in [one, two] + list(args)]), - ', '.join(['%s=%s' % (k, v) for (k, v) in sorted_kwarg]) + ', '.join(six.text_type(arg) for arg in [one, two] + list(args)), + ', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg) ) assignment_unlimited_args_kwargs.anything = "Expected assignment_unlimited_args_kwargs __dict__" diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 74aec32394..876fb448f5 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -507,7 +507,7 @@ class TemplateTests(TransRealMixin, TestCase): template_tests.update(filter_tests) cache_loader = setup_test_template_loader( - dict([(name, t[0]) for name, t in six.iteritems(template_tests)]), + dict((name, t[0]) for name, t in six.iteritems(template_tests)), use_cached_loader=True, ) |
