Fixed #21267 -- Fixed E502 pep8 warnings

This commit is contained in:
Alasdair Nicol 2013-10-18 01:24:41 +01:00
parent dfb4cb9970
commit 65d1d65d52
11 changed files with 46 additions and 46 deletions

View File

@ -126,8 +126,8 @@ class CookieTest(BaseTests, TestCase):
messages = [ messages = [
{ {
'message': Message(constants.INFO, 'Test message'), 'message': Message(constants.INFO, 'Test message'),
'message_list': [Message(constants.INFO, 'message %s') \ 'message_list': [Message(constants.INFO, 'message %s')
for x in range(5)] + [{'another-message': \ for x in range(5)] + [{'another-message':
Message(constants.ERROR, 'error')}], Message(constants.ERROR, 'error')}],
}, },
Message(constants.INFO, 'message %s'), Message(constants.INFO, 'message %s'),

View File

@ -14,7 +14,7 @@ class CurrentSiteManager(models.Manager):
# If a custom name is provided, make sure the field exists on the model # If a custom name is provided, make sure the field exists on the model
if self.__field_name is not None and self.__field_name not in field_names: if self.__field_name is not None and self.__field_name not in field_names:
raise ValueError("%s couldn't find a field named %s in %s." % \ raise ValueError("%s couldn't find a field named %s in %s." %
(self.__class__.__name__, self.__field_name, self.model._meta.object_name)) (self.__class__.__name__, self.__field_name, self.model._meta.object_name))
# Otherwise, see if there is a field called either 'site' or 'sites' # Otherwise, see if there is a field called either 'site' or 'sites'
@ -31,7 +31,7 @@ class CurrentSiteManager(models.Manager):
if not isinstance(field, (models.ForeignKey, models.ManyToManyField)): if not isinstance(field, (models.ForeignKey, models.ManyToManyField)):
raise TypeError("%s must be a ForeignKey or ManyToManyField." %self.__field_name) raise TypeError("%s must be a ForeignKey or ManyToManyField." %self.__field_name)
except FieldDoesNotExist: except FieldDoesNotExist:
raise ValueError("%s couldn't find a field named %s in %s." % \ raise ValueError("%s couldn't find a field named %s in %s." %
(self.__class__.__name__, self.__field_name, self.model._meta.object_name)) (self.__class__.__name__, self.__field_name, self.model._meta.object_name))
self.__is_validated = True self.__is_validated = True

View File

@ -262,7 +262,7 @@ class ManagementUtility(object):
try: try:
app_name = commands[subcommand] app_name = commands[subcommand]
except KeyError: except KeyError:
sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % \ sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" %
(subcommand, self.prog_name)) (subcommand, self.prog_name))
sys.exit(1) sys.exit(1)
if isinstance(app_name, BaseCommand): if isinstance(app_name, BaseCommand):

View File

@ -63,7 +63,7 @@ class Command(BaseCommand):
field_output.append("UNIQUE") field_output.append("UNIQUE")
if f.db_index: if f.db_index:
unique = "UNIQUE " if f.unique else "" unique = "UNIQUE " if f.unique else ""
index_output.append("CREATE %sINDEX %s ON %s (%s);" % \ index_output.append("CREATE %sINDEX %s ON %s (%s);" %
(unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename),
qn(f.name))) qn(f.name)))
table_output.append(" ".join(field_output)) table_output.append(" ".join(field_output))

View File

@ -24,5 +24,5 @@ class Command(BaseCommand):
# isn't installed. There's a possibility OSError would be raised # isn't installed. There's a possibility OSError would be raised
# for some other reason, in which case this error message would be # for some other reason, in which case this error message would be
# inaccurate. Still, this message catches the common case. # inaccurate. Still, this message catches the common case.
raise CommandError('You appear not to have the %r program installed or on your path.' % \ raise CommandError('You appear not to have the %r program installed or on your path.' %
connection.client.executable_name) connection.client.executable_name)

View File

@ -271,7 +271,7 @@ class Deserializer(base.Deserializer):
model_identifier = node.getAttribute(attr) model_identifier = node.getAttribute(attr)
if not model_identifier: if not model_identifier:
raise base.DeserializationError( raise base.DeserializationError(
"<%s> node is missing the required '%s' attribute" \ "<%s> node is missing the required '%s' attribute"
% (node.nodeName, attr)) % (node.nodeName, attr))
try: try:
Model = models.get_model(*model_identifier.split(".")) Model = models.get_model(*model_identifier.split("."))
@ -279,7 +279,7 @@ class Deserializer(base.Deserializer):
Model = None Model = None
if Model is None: if Model is None:
raise base.DeserializationError( raise base.DeserializationError(
"<%s> node has invalid model identifier: '%s'" % \ "<%s> node has invalid model identifier: '%s'" %
(node.nodeName, model_identifier)) (node.nodeName, model_identifier))
return Model return Model

View File

@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8] [flake8]
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,E303,E502,F401,F403,F841,W601 ignore=E123,E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,E303,F401,F403,F841,W601
[metadata] [metadata]
license-file = LICENSE license-file = LICENSE

View File

@ -168,7 +168,7 @@ class ChangeListTests(TestCase):
m.list_display = ['id', 'name', 'parent'] m.list_display = ['id', 'name', 'parent']
m.list_display_links = ['id'] m.list_display_links = ['id']
m.list_editable = ['name'] m.list_editable = ['name']
self.assertRaises(IncorrectLookupParameters, lambda: \ self.assertRaises(IncorrectLookupParameters, lambda:
ChangeList(request, Child, m.list_display, m.list_display_links, ChangeList(request, Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields, m.list_filter, m.date_hierarchy, m.search_fields,
m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m)) m.list_select_related, m.list_per_page, m.list_max_show_all, m.list_editable, m))

View File

@ -54,7 +54,7 @@ class AdminFormfieldForDBFieldTests(TestCase):
# Check that we got a field of the right type # Check that we got a field of the right type
self.assertTrue( self.assertTrue(
isinstance(widget, widgetclass), isinstance(widget, widgetclass),
"Wrong widget for %s.%s: expected %s, got %s" % \ "Wrong widget for %s.%s: expected %s, got %s" %
(model.__class__.__name__, fieldname, widgetclass, type(widget)) (model.__class__.__name__, fieldname, widgetclass, type(widget))
) )

View File

@ -124,7 +124,7 @@ class DefaultFiltersTests(TestCase):
self.assertEqual(linenumbers('line 1\nline 2'), self.assertEqual(linenumbers('line 1\nline 2'),
'1. line 1\n2. line 2') '1. line 1\n2. line 2')
self.assertEqual(linenumbers('\n'.join(['x'] * 10)), self.assertEqual(linenumbers('\n'.join(['x'] * 10)),
'01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. '\ '01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. '
'x\n08. x\n09. x\n10. x') 'x\n08. x\n09. x\n10. x')
def test_lower(self): def test_lower(self):
@ -138,7 +138,7 @@ class DefaultFiltersTests(TestCase):
self.assertEqual(make_list(1234), ['1', '2', '3', '4']) self.assertEqual(make_list(1234), ['1', '2', '3', '4'])
def test_slugify(self): def test_slugify(self):
self.assertEqual(slugify(' Jack & Jill like numbers 1,2,3 and 4 and'\ self.assertEqual(slugify(' Jack & Jill like numbers 1,2,3 and 4 and'
' silly characters ?%.$!/'), ' silly characters ?%.$!/'),
'jack-jill-like-numbers-123-and-4-and-silly-characters') 'jack-jill-like-numbers-123-and-4-and-silly-characters')
@ -170,7 +170,7 @@ class DefaultFiltersTests(TestCase):
def test_truncatewords_html(self): def test_truncatewords_html(self):
self.assertEqual(truncatewords_html( self.assertEqual(truncatewords_html(
'<p>one <a href="#">two - three <br>four</a> five</p>', 0), '') '<p>one <a href="#">two - three <br>four</a> five</p>', 0), '')
self.assertEqual(truncatewords_html('<p>one <a href="#">two - '\ self.assertEqual(truncatewords_html('<p>one <a href="#">two - '
'three <br>four</a> five</p>', 2), 'three <br>four</a> five</p>', 2),
'<p>one <a href="#">two ...</a></p>') '<p>one <a href="#">two ...</a></p>')
self.assertEqual(truncatewords_html( self.assertEqual(truncatewords_html(
@ -205,17 +205,17 @@ class DefaultFiltersTests(TestCase):
'fran%C3%A7ois%20%26%20jill') 'fran%C3%A7ois%20%26%20jill')
def test_urlizetrunc(self): def test_urlizetrunc(self):
self.assertEqual(urlizetrunc('http://short.com/', 20), '<a href='\ self.assertEqual(urlizetrunc('http://short.com/', 20), '<a href='
'"http://short.com/" rel="nofollow">http://short.com/</a>') '"http://short.com/" rel="nofollow">http://short.com/</a>')
self.assertEqual(urlizetrunc('http://www.google.co.uk/search?hl=en'\ self.assertEqual(urlizetrunc('http://www.google.co.uk/search?hl=en'
'&q=some+long+url&btnG=Search&meta=', 20), '<a href="http://'\ '&q=some+long+url&btnG=Search&meta=', 20), '<a href="http://'
'www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&'\ 'www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&'
'meta=" rel="nofollow">http://www.google...</a>') 'meta=" rel="nofollow">http://www.google...</a>')
self.assertEqual(urlizetrunc('http://www.google.co.uk/search?hl=en'\ self.assertEqual(urlizetrunc('http://www.google.co.uk/search?hl=en'
'&q=some+long+url&btnG=Search&meta=', 20), '<a href="http://'\ '&q=some+long+url&btnG=Search&meta=', 20), '<a href="http://'
'www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search'\ 'www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search'
'&meta=" rel="nofollow">http://www.google...</a>') '&meta=" rel="nofollow">http://www.google...</a>')
# Check truncating of URIs which are the exact length # Check truncating of URIs which are the exact length
@ -223,15 +223,15 @@ class DefaultFiltersTests(TestCase):
self.assertEqual(len(uri), 31) self.assertEqual(len(uri), 31)
self.assertEqual(urlizetrunc(uri, 31), self.assertEqual(urlizetrunc(uri, 31),
'<a href="http://31characteruri.com/test/" rel="nofollow">'\ '<a href="http://31characteruri.com/test/" rel="nofollow">'
'http://31characteruri.com/test/</a>') 'http://31characteruri.com/test/</a>')
self.assertEqual(urlizetrunc(uri, 30), self.assertEqual(urlizetrunc(uri, 30),
'<a href="http://31characteruri.com/test/" rel="nofollow">'\ '<a href="http://31characteruri.com/test/" rel="nofollow">'
'http://31characteruri.com/t...</a>') 'http://31characteruri.com/t...</a>')
self.assertEqual(urlizetrunc(uri, 2), self.assertEqual(urlizetrunc(uri, 2),
'<a href="http://31characteruri.com/test/"'\ '<a href="http://31characteruri.com/test/"'
' rel="nofollow">...</a>') ' rel="nofollow">...</a>')
def test_urlize(self): def test_urlize(self):
@ -350,18 +350,18 @@ class DefaultFiltersTests(TestCase):
self.assertEqual(wordcount('oneword'), 1) self.assertEqual(wordcount('oneword'), 1)
self.assertEqual(wordcount('lots of words'), 3) self.assertEqual(wordcount('lots of words'), 3)
self.assertEqual(wordwrap('this is a long paragraph of text that '\ self.assertEqual(wordwrap('this is a long paragraph of text that '
'really needs to be wrapped I\'m afraid', 14), 'really needs to be wrapped I\'m afraid', 14),
"this is a long\nparagraph of\ntext that\nreally needs\nto be "\ "this is a long\nparagraph of\ntext that\nreally needs\nto be "
"wrapped\nI'm afraid") "wrapped\nI'm afraid")
self.assertEqual(wordwrap('this is a short paragraph of text.\n '\ self.assertEqual(wordwrap('this is a short paragraph of text.\n '
'But this line should be indented', 14), 'But this line should be indented', 14),
'this is a\nshort\nparagraph of\ntext.\n But this\nline '\ 'this is a\nshort\nparagraph of\ntext.\n But this\nline '
'should be\nindented') 'should be\nindented')
self.assertEqual(wordwrap('this is a short paragraph of text.\n '\ self.assertEqual(wordwrap('this is a short paragraph of text.\n '
'But this line should be indented',15), 'this is a short\n'\ 'But this line should be indented',15), 'this is a short\n'
'paragraph of\ntext.\n But this line\nshould be\nindented') 'paragraph of\ntext.\n But this line\nshould be\nindented')
def test_rjust(self): def test_rjust(self):
@ -388,7 +388,7 @@ class DefaultFiltersTests(TestCase):
self.assertIsInstance(escaped, SafeData) self.assertIsInstance(escaped, SafeData)
self.assertEqual( self.assertEqual(
force_escape('<some html & special characters > here ĐÅ€£'), force_escape('<some html & special characters > here ĐÅ€£'),
'&lt;some html &amp; special characters &gt; here'\ '&lt;some html &amp; special characters &gt; here'
' \u0110\xc5\u20ac\xa3') ' \u0110\xc5\u20ac\xa3')
def test_linebreaks(self): def test_linebreaks(self):
@ -409,10 +409,10 @@ class DefaultFiltersTests(TestCase):
'line 1<br />line 2') 'line 1<br />line 2')
def test_removetags(self): def test_removetags(self):
self.assertEqual(removetags('some <b>html</b> with <script>alert'\ self.assertEqual(removetags('some <b>html</b> with <script>alert'
'("You smell")</script> disallowed <img /> tags', 'script img'), '("You smell")</script> disallowed <img /> tags', 'script img'),
'some <b>html</b> with alert("You smell") disallowed tags') 'some <b>html</b> with alert("You smell") disallowed tags')
self.assertEqual(striptags('some <b>html</b> with <script>alert'\ self.assertEqual(striptags('some <b>html</b> with <script>alert'
'("You smell")</script> disallowed <img /> tags'), '("You smell")</script> disallowed <img /> tags'),
'some html with alert("You smell") disallowed tags') 'some html with alert("You smell") disallowed tags')
@ -483,20 +483,20 @@ class DefaultFiltersTests(TestCase):
self.assertEqual( self.assertEqual(
unordered_list(['item 1', ['item 1.1', 'item1.2'], 'item 2']), unordered_list(['item 1', ['item 1.1', 'item1.2'], 'item 2']),
'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item1.2'\ '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item1.2'
'</li>\n\t</ul>\n\t</li>\n\t<li>item 2</li>') '</li>\n\t</ul>\n\t</li>\n\t<li>item 2</li>')
self.assertEqual( self.assertEqual(
unordered_list(['item 1', ['item 1.1', ['item 1.1.1', unordered_list(['item 1', ['item 1.1', ['item 1.1.1',
['item 1.1.1.1']]]]), ['item 1.1.1.1']]]]),
'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1\n\t\t<ul>\n\t\t\t<li>'\ '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1\n\t\t<ul>\n\t\t\t<li>'
'item 1.1.1\n\t\t\t<ul>\n\t\t\t\t<li>item 1.1.1.1</li>\n\t\t\t'\ 'item 1.1.1\n\t\t\t<ul>\n\t\t\t\t<li>item 1.1.1.1</li>\n\t\t\t'
'</ul>\n\t\t\t</li>\n\t\t</ul>\n\t\t</li>\n\t</ul>\n\t</li>') '</ul>\n\t\t\t</li>\n\t\t</ul>\n\t\t</li>\n\t</ul>\n\t</li>')
self.assertEqual(unordered_list( self.assertEqual(unordered_list(
['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]), ['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]),
'\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>'\ '\t<li>States\n\t<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>'
'Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>'\ 'Lawrence</li>\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>'
'\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>') '\n\t\t<li>Illinois</li>\n\t</ul>\n\t</li>')
@python_2_unicode_compatible @python_2_unicode_compatible
@ -518,13 +518,13 @@ class DefaultFiltersTests(TestCase):
'\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>') '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>')
self.assertEqual(unordered_list(['item 1', [['item 1.1', []], self.assertEqual(unordered_list(['item 1', [['item 1.1', []],
['item 1.2', []]]]), '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1'\ ['item 1.2', []]]]), '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1'
'</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>') '</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>')
self.assertEqual(unordered_list(['States', [['Kansas', [['Lawrence', self.assertEqual(unordered_list(['States', [['Kansas', [['Lawrence',
[]], ['Topeka', []]]], ['Illinois', []]]]), '\t<li>States\n\t'\ []], ['Topeka', []]]], ['Illinois', []]]]), '\t<li>States\n\t'
'<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>'\ '<ul>\n\t\t<li>Kansas\n\t\t<ul>\n\t\t\t<li>Lawrence</li>'
'\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>'\ '\n\t\t\t<li>Topeka</li>\n\t\t</ul>\n\t\t</li>\n\t\t<li>'
'Illinois</li>\n\t</ul>\n\t</li>') 'Illinois</li>\n\t</ul>\n\t</li>')
def test_add(self): def test_add(self):

View File

@ -51,15 +51,15 @@ class DistinctOnTests(TestCase):
['<Staff: p1>', '<Staff: p1>', '<Staff: p2>', '<Staff: p3>'], ['<Staff: p1>', '<Staff: p1>', '<Staff: p2>', '<Staff: p3>'],
), ),
( (
Celebrity.objects.filter(fan__in=[self.fan1, self.fan2, self.fan3]).\ Celebrity.objects.filter(fan__in=[self.fan1, self.fan2, self.fan3]).
distinct('name').order_by('name'), distinct('name').order_by('name'),
['<Celebrity: c1>', '<Celebrity: c2>'], ['<Celebrity: c1>', '<Celebrity: c2>'],
), ),
# Does combining querysets work? # Does combining querysets work?
( (
(Celebrity.objects.filter(fan__in=[self.fan1, self.fan2]).\ (Celebrity.objects.filter(fan__in=[self.fan1, self.fan2]).
distinct('name').order_by('name') distinct('name').order_by('name')
|Celebrity.objects.filter(fan__in=[self.fan3]).\ |Celebrity.objects.filter(fan__in=[self.fan3]).
distinct('name').order_by('name')), distinct('name').order_by('name')),
['<Celebrity: c1>', '<Celebrity: c2>'], ['<Celebrity: c1>', '<Celebrity: c2>'],
), ),