Permalink
Browse files

Fixed the build after flake8 update

  • Loading branch information...
1 parent 064578d commit e3a0b21924f35983717a2e3e326aeb3b872d19e0 @brutasse brutasse committed Jul 27, 2012
View
2 .travis.yml
@@ -16,7 +16,7 @@ install:
- pip install -e .
- pip install -r requirements/tests.txt Django==$DJANGO_VERSION
before_script:
- - flake8 floppyforms --ignore=E501
+ - flake8 floppyforms --ignore=E5,E123,E125,E126
script:
- make test
branches:
View
4 floppyforms/gis/widgets.py
@@ -163,9 +163,9 @@ class BaseGMapWidget(BaseGeometryWidget):
template_name = 'floppyforms/gis/google.html'
class Media:
+ # FIXME: use proper Openlayers release
js = (
- 'http://openlayers.org/dev/OpenLayers.js', # FIXME: use 2.11
- # when it's out
+ 'http://openlayers.org/dev/OpenLayers.js',
'floppyforms/js/MapWidget.js',
'http://maps.google.com/maps/api/js?sensor=false',
)
View
17 floppyforms/tests/base.py
@@ -78,10 +78,12 @@ def assertTemplateUsed(self, response=None, template_name=None, msg_prefix=''):
template_names = [t.name for t in response.templates]
if not template_names:
self.fail(msg_prefix + "No templates used to render the response")
- self.assertTrue(template_name in template_names,
+ self.assertTrue(
+ template_name in template_names,
msg_prefix + "Template '%s' was not a template used to render"
" the response. Actual template(s) used: %s" %
- (template_name, u', '.join(template_names)))
+ (template_name, u', '.join(template_names))
+ )
def assertTemplateNotUsed(self, response=None, template_name=None, msg_prefix=''):
"""
@@ -103,7 +105,8 @@ def assertTemplateNotUsed(self, response=None, template_name=None, msg_prefix=''
return context
template_names = [t.name for t in response.templates]
- self.assertFalse(template_name in template_names,
+ self.assertFalse(
+ template_name in template_names,
msg_prefix + "Template '%s' was used unexpectedly in rendering"
" the response" % template_name)
@@ -125,9 +128,9 @@ def assertHTMLEqual(self, html1, html2, msg=None):
significant. The passed-in arguments must be valid HTML.
"""
dom1 = assert_and_parse_html(self, html1, msg,
- u'First argument is not valid HTML:')
+ u'First argument is not valid HTML:')
dom2 = assert_and_parse_html(self, html2, msg,
- u'Second argument is not valid HTML:')
+ u'Second argument is not valid HTML:')
if dom1 != dom2:
standardMsg = '%s != %s' % (
@@ -141,9 +144,9 @@ def assertHTMLEqual(self, html1, html2, msg=None):
def assertHTMLNotEqual(self, html1, html2, msg=None):
"""Asserts that two HTML snippets are not semantically equivalent."""
dom1 = assert_and_parse_html(self, html1, msg,
- u'First argument is not valid HTML:')
+ u'First argument is not valid HTML:')
dom2 = assert_and_parse_html(self, html2, msg,
- u'Second argument is not valid HTML:')
+ u'Second argument is not valid HTML:')
if dom1 == dom2:
standardMsg = '%s == %s' % (
View
6 floppyforms/tests/forms.py
@@ -11,8 +11,10 @@ class RegistrationForm(forms.Form):
firstname = forms.CharField(label=_(u'Your first name?'))
lastname = forms.CharField(label=_(u'Your last name:'))
username = forms.CharField(max_length=30)
- password = forms.CharField(widget=forms.PasswordInput,
- help_text=_(u'Make sure to use a secure password.'))
+ password = forms.CharField(
+ widget=forms.PasswordInput,
+ help_text=_(u'Make sure to use a secure password.'),
+ )
password2 = forms.CharField(label=_(u'Retype password'), widget=forms.PasswordInput)
age = forms.IntegerField(required=False)
View
2 floppyforms/tests/html.py
@@ -142,7 +142,7 @@ def __unicode__(self):
class Parser(HTMLParser):
SELF_CLOSING_TAGS = ('br', 'hr', 'input', 'img', 'meta', 'spacer',
- 'link', 'frame', 'base', 'col')
+ 'link', 'frame', 'base', 'col')
def __init__(self):
HTMLParser.__init__(self)
View
8 floppyforms/tests/html_parser.py
@@ -45,8 +45,8 @@ def parse_starttag(self, i):
attrname, rest, attrvalue = m.group(1, 2, 3)
if not rest:
attrvalue = None
- elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
- attrvalue[:1] == '"' == attrvalue[-1:]:
+ elif (attrvalue[:1] == '\'' == attrvalue[-1:] or
+ attrvalue[:1] == '"' == attrvalue[-1:]):
attrvalue = attrvalue[1:-1]
attrvalue = self.unescape(attrvalue)
attrs.append((attrname.lower(), attrvalue))
@@ -57,8 +57,8 @@ def parse_starttag(self, i):
lineno, offset = self.getpos()
if "\n" in self.__starttag_text:
lineno = lineno + self.__starttag_text.count("\n")
- offset = len(self.__starttag_text) \
- - self.__starttag_text.rfind("\n")
+ offset = (len(self.__starttag_text) -
+ self.__starttag_text.rfind("\n"))
else:
offset = offset + len(self.__starttag_text)
self.error("junk characters in start tag: %r"
View
6 floppyforms/tests/layouts.py
@@ -31,8 +31,10 @@ class RegistrationForm(forms.Form):
firstname = forms.CharField(label=_(u'Your first name?'))
lastname = forms.CharField(label=_(u'Your last name:'))
username = forms.CharField(max_length=30)
- password = forms.CharField(widget=forms.PasswordInput,
- help_text=_(u'Make sure to use a secure password.'))
+ password = forms.CharField(
+ widget=forms.PasswordInput,
+ help_text=_(u'Make sure to use a secure password.'),
+ )
password2 = forms.CharField(label=_(u'Retype password'), widget=forms.PasswordInput)
age = forms.IntegerField(required=False)
View
32 floppyforms/tests/rendering.py
@@ -12,7 +12,7 @@ class AgeField(forms.IntegerField):
class RegistrationForm(forms.Form):
name = forms.CharField(label='First- and Lastname', max_length=50)
email = forms.EmailField(max_length=50,
- help_text='Please enter a valid email.')
+ help_text='Please enter a valid email.')
age = AgeField()
short_biography = forms.CharField(max_length=200)
comment = forms.CharField(widget=widgets.Textarea)
@@ -90,10 +90,14 @@ def test_retrieve_for_multiple_valid_values(self):
form = RegistrationForm()
config = FormConfig()
- config.configure('widget', widgets.Textarea(),
- filter=ConfigFilter('CharField'))
- config.configure('widget', widgets.HiddenInput(),
- filter=ConfigFilter('short_biography'))
+ config.configure(
+ 'widget', widgets.Textarea(),
+ filter=ConfigFilter('CharField'),
+ )
+ config.configure(
+ 'widget', widgets.HiddenInput(),
+ filter=ConfigFilter('short_biography'),
+ )
widget = config.retrieve('widget', bound_field=form['name'])
self.assertEqual(widget.__class__, widgets.Textarea)
@@ -110,12 +114,16 @@ def test_stacked_config(self):
config = FormConfig()
config.push()
- config.configure('widget', widgets.Textarea(),
- filter=ConfigFilter("CharField"))
+ config.configure(
+ 'widget', widgets.Textarea(),
+ filter=ConfigFilter("CharField"),
+ )
config.push()
- config.configure('widget', widgets.HiddenInput(),
- filter=ConfigFilter('short_biography'))
+ config.configure(
+ 'widget', widgets.HiddenInput(),
+ filter=ConfigFilter('short_biography'),
+ )
widget = config.retrieve('widget', bound_field=form['short_biography'])
self.assertEqual(widget.__class__, widgets.HiddenInput)
@@ -132,8 +140,10 @@ def test_field_filter_works_on_subclasses(self):
form = RegistrationForm()
config = FormConfig()
- config.configure('widget', widgets.HiddenInput(),
- filter=ConfigFilter("IntegerField"))
+ config.configure(
+ 'widget', widgets.HiddenInput(),
+ filter=ConfigFilter("IntegerField"),
+ )
widget = config.retrieve('widget', bound_field=form['age'])
self.assertEqual(widget.__class__, widgets.HiddenInput)
View
21 floppyforms/tests/templatetags.py
@@ -4,7 +4,8 @@
import floppyforms as forms
from floppyforms.templatetags.floppyforms import (FormConfig, ConfigFilter,
- FormNode, RowModifier, FieldModifier)
+ FormNode, RowModifier,
+ FieldModifier)
from .base import FloppyFormsTestCase
@@ -288,7 +289,8 @@ def test_inline_content(self):
""", {'f1': SimpleForm(), 'f2': SimpleForm()}), 'Equals!')
# none forms are not included in form list
- self.assertHTMLEqual(render("""
+ self.assertHTMLEqual(
+ render("""
{% form f1 nothing f2 more_of_nothing using %}
{% if f1 == forms.0 and f2 == forms.1 %}
{% if forms.2 == None and more_of_nothing == None %}
@@ -612,27 +614,30 @@ def test_only_option(self):
def test_configure_template_with_extra_context(self):
form = SimpleForm()
with self.assertTemplateUsed('simple_formfield_tag.html'):
- self.assertHTMLEqual(render("""{% form myform using %}
+ self.assertHTMLEqual(
+ render("""{% form myform using %}
{% formconfig field using "simple_formfield_tag.html" %}
{% formfield form.name with extra_argument="I want bacon!" %}
{% endform %}""", {'myform': form}),
- "Type: text Extra argument: I want bacon!")
+ "Type: text Extra argument: I want bacon!")
def test_configure_extra_context(self):
form = SimpleForm()
- self.assertHTMLEqual(render("""{% form myform using %}
+ self.assertHTMLEqual(
+ render("""{% form myform using %}
{% formconfig field with extra_argument="I want spam!" %}
{% formconfig field with extra_argument="I want ham!" %}
{% formfield form.name using "simple_formfield_tag.html" %}
{% endform %}""", {'myform': form}),
- "Type: text Extra argument: I want ham!")
+ "Type: text Extra argument: I want ham!")
context = Context({'myform': form})
- self.assertHTMLEqual(render("""{% form myform using %}
+ self.assertHTMLEqual(
+ render("""{% form myform using %}
{% formconfig field using "simple_formfield_tag.html" with extra_argument="I want ham!" %}
{% formfield form.name %}
{% endform %}""", context),
- "Type: text Extra argument: I want ham!")
+ "Type: text Extra argument: I want ham!")
def test_change_widget(self):
form = SimpleForm()
View
2 floppyforms/widgets.py
@@ -596,7 +596,7 @@ def get_context(self, name, value, attrs=None, extra_context={}):
# for things like "checked", set the value to False so that the
# template doesn't render checked="".
for key, value in attrs.items():
- if value == True:
+ if value is True:
attrs[key] = False
context['year_id'] = self.year_field % attrs['id']
context['month_id'] = self.month_field % attrs['id']

0 comments on commit e3a0b21

Please sign in to comment.