Fixed "indentation is not a multiple of four" pep8 issues.
This commit is contained in:
parent
cb98ffe8f4
commit
5649c0af9d
|
@ -28,7 +28,7 @@ def lookup_needs_distinct(opts, lookup_path):
|
|||
isinstance(field.rel, models.ManyToManyRel)) or
|
||||
(isinstance(field, models.related.RelatedObject) and
|
||||
not field.field.unique)):
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def prepare_lookup_value(key, value):
|
||||
|
|
|
@ -252,10 +252,10 @@ def wkb_r():
|
|||
return thread_context.wkb_r
|
||||
|
||||
def wkb_w(dim=2):
|
||||
if not thread_context.wkb_w:
|
||||
thread_context.wkb_w = WKBWriter()
|
||||
thread_context.wkb_w.outdim = dim
|
||||
return thread_context.wkb_w
|
||||
if not thread_context.wkb_w:
|
||||
thread_context.wkb_w = WKBWriter()
|
||||
thread_context.wkb_w.outdim = dim
|
||||
return thread_context.wkb_w
|
||||
|
||||
def ewkb_w(dim=2):
|
||||
if not thread_context.ewkb_w:
|
||||
|
|
|
@ -58,14 +58,14 @@ class GeoRegressionTests(TestCase):
|
|||
self.assertEqual(founded, PennsylvaniaCity.objects.aggregate(Min('founded'))['founded__min'])
|
||||
|
||||
def test_empty_count(self):
|
||||
"Testing that PostGISAdapter.__eq__ does check empty strings. See #13670."
|
||||
# contrived example, but need a geo lookup paired with an id__in lookup
|
||||
pueblo = City.objects.get(name='Pueblo')
|
||||
state = State.objects.filter(poly__contains=pueblo.point)
|
||||
cities_within_state = City.objects.filter(id__in=state)
|
||||
"Testing that PostGISAdapter.__eq__ does check empty strings. See #13670."
|
||||
# contrived example, but need a geo lookup paired with an id__in lookup
|
||||
pueblo = City.objects.get(name='Pueblo')
|
||||
state = State.objects.filter(poly__contains=pueblo.point)
|
||||
cities_within_state = City.objects.filter(id__in=state)
|
||||
|
||||
# .count() should not throw TypeError in __eq__
|
||||
self.assertEqual(cities_within_state.count(), 1)
|
||||
# .count() should not throw TypeError in __eq__
|
||||
self.assertEqual(cities_within_state.count(), 1)
|
||||
|
||||
def test_defer_or_only_with_annotate(self):
|
||||
"Regression for #16409. Make sure defer() and only() work with annotate()"
|
||||
|
|
|
@ -31,14 +31,15 @@ def add_level_messages(storage):
|
|||
|
||||
|
||||
class override_settings_tags(override_settings):
|
||||
def enable(self):
|
||||
def enable(self):
|
||||
super(override_settings_tags, self).enable()
|
||||
# LEVEL_TAGS is a constant defined in the
|
||||
# django.contrib.messages.storage.base module, so after changing
|
||||
# settings.MESSAGE_TAGS, we need to update that constant too.
|
||||
self.old_level_tags = base.LEVEL_TAGS
|
||||
base.LEVEL_TAGS = utils.get_level_tags()
|
||||
def disable(self):
|
||||
|
||||
def disable(self):
|
||||
super(override_settings_tags, self).disable()
|
||||
base.LEVEL_TAGS = self.old_level_tags
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ def getInnerText(node):
|
|||
elif child.nodeType == child.ELEMENT_NODE:
|
||||
inner_text.extend(getInnerText(child))
|
||||
else:
|
||||
pass
|
||||
pass
|
||||
return "".join(inner_text)
|
||||
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ def parse_accept_lang_header(lang_string):
|
|||
if priority:
|
||||
priority = float(priority)
|
||||
if not priority: # if priority is 0.0 at this point make it 1.0
|
||||
priority = 1.0
|
||||
priority = 1.0
|
||||
result.append((lang, priority))
|
||||
result.sort(key=lambda k: k[1], reverse=True)
|
||||
return result
|
||||
|
|
|
@ -244,14 +244,14 @@ class ValidationTestCase(TestCase):
|
|||
|
||||
def test_nested_fields(self):
|
||||
class NestedFieldsAdmin(admin.ModelAdmin):
|
||||
fields = ('price', ('name', 'subtitle'))
|
||||
fields = ('price', ('name', 'subtitle'))
|
||||
NestedFieldsAdmin.validate(Book)
|
||||
|
||||
def test_nested_fieldsets(self):
|
||||
class NestedFieldsetAdmin(admin.ModelAdmin):
|
||||
fieldsets = (
|
||||
('Main', {'fields': ('price', ('name', 'subtitle'))}),
|
||||
)
|
||||
fieldsets = (
|
||||
('Main', {'fields': ('price', ('name', 'subtitle'))}),
|
||||
)
|
||||
NestedFieldsetAdmin.validate(Book)
|
||||
|
||||
def test_explicit_through_override(self):
|
||||
|
|
|
@ -43,17 +43,17 @@ class HiddenInventoryManager(models.Manager):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class Inventory(models.Model):
|
||||
barcode = models.PositiveIntegerField(unique=True)
|
||||
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
|
||||
name = models.CharField(blank=False, max_length=20)
|
||||
hidden = models.BooleanField(default=False)
|
||||
barcode = models.PositiveIntegerField(unique=True)
|
||||
parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
|
||||
name = models.CharField(blank=False, max_length=20)
|
||||
hidden = models.BooleanField(default=False)
|
||||
|
||||
# see #9258
|
||||
default_manager = models.Manager()
|
||||
objects = HiddenInventoryManager()
|
||||
# see #9258
|
||||
default_manager = models.Manager()
|
||||
objects = HiddenInventoryManager()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Event(models.Model):
|
||||
main_band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0), related_name='events_main_band_at')
|
||||
|
|
|
@ -29,12 +29,12 @@ class CustomManagerTests(TestCase):
|
|||
manager.public_method()
|
||||
# Don't copy private methods.
|
||||
with self.assertRaises(AttributeError):
|
||||
manager._private_method()
|
||||
manager._private_method()
|
||||
# Copy methods with `manager=True` even if they are private.
|
||||
manager._optin_private_method()
|
||||
# Don't copy methods with `manager=False` even if they are public.
|
||||
with self.assertRaises(AttributeError):
|
||||
manager.optout_public_method()
|
||||
manager.optout_public_method()
|
||||
|
||||
# Test that the overridden method is called.
|
||||
queryset = manager.filter()
|
||||
|
|
|
@ -481,7 +481,7 @@ class DefaultFiltersTests(TestCase):
|
|||
@python_2_unicode_compatible
|
||||
class ULItem(object):
|
||||
def __init__(self, title):
|
||||
self.title = title
|
||||
self.title = title
|
||||
def __str__(self):
|
||||
return 'ulitem-%s' % str(self.title)
|
||||
|
||||
|
|
|
@ -1173,9 +1173,9 @@ class FormsTestCase(TestCase):
|
|||
# If a Form defines 'initial' *and* 'initial' is passed as a parameter to Form(),
|
||||
# then the latter will get precedence.
|
||||
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)
|
||||
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)
|
||||
|
||||
p = UserRegistration(auto_id=False)
|
||||
self.assertHTMLEqual(p.as_ul(), """<li>Username: <input type="text" name="username" value="django" maxlength="10" /></li>
|
||||
|
|
|
@ -366,7 +366,7 @@ class FormsFormsetTestCase(TestCase):
|
|||
# it's going to be deleted.
|
||||
|
||||
class CheckForm(Form):
|
||||
field = IntegerField(min_value=100)
|
||||
field = IntegerField(min_value=100)
|
||||
|
||||
data = {
|
||||
'check-TOTAL_FORMS': '3', # the number of forms rendered
|
||||
|
@ -978,7 +978,7 @@ class FormsFormsetTestCase(TestCase):
|
|||
|
||||
def test_validate_max_ignores_forms_marked_for_deletion(self):
|
||||
class CheckForm(Form):
|
||||
field = IntegerField()
|
||||
field = IntegerField()
|
||||
|
||||
data = {
|
||||
'check-TOTAL_FORMS': '2',
|
||||
|
|
|
@ -639,8 +639,8 @@ 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)
|
||||
def render(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 />
|
||||
|
@ -649,7 +649,7 @@ beatle J R Ringo False""")
|
|||
|
||||
# Or you can use custom RadioSelect fields that use your custom renderer.
|
||||
class CustomRadioSelect(RadioSelect):
|
||||
renderer = MyRenderer
|
||||
renderer = MyRenderer
|
||||
w = CustomRadioSelect()
|
||||
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 />
|
||||
|
|
|
@ -14,21 +14,23 @@ from django.utils.encoding import python_2_unicode_compatible
|
|||
@python_2_unicode_compatible
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
ordering = ('name',)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Article(models.Model):
|
||||
headline = models.CharField(max_length=50)
|
||||
pub_date = models.DateTimeField()
|
||||
primary_categories = models.ManyToManyField(Category, related_name='primary_article_set')
|
||||
secondary_categories = models.ManyToManyField(Category, related_name='secondary_article_set')
|
||||
|
||||
class Meta:
|
||||
ordering = ('pub_date',)
|
||||
ordering = ('pub_date',)
|
||||
|
||||
def __str__(self):
|
||||
return self.headline
|
||||
|
||||
|
|
|
@ -88,11 +88,11 @@ class DerivedPostForm(forms.ModelForm):
|
|||
|
||||
|
||||
class CustomWriterForm(forms.ModelForm):
|
||||
name = forms.CharField(required=False)
|
||||
name = forms.CharField(required=False)
|
||||
|
||||
class Meta:
|
||||
model = Writer
|
||||
fields = '__all__'
|
||||
class Meta:
|
||||
model = Writer
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class FlexDatePostForm(forms.ModelForm):
|
||||
|
@ -456,11 +456,11 @@ class ModelFormBaseTest(TestCase):
|
|||
|
||||
def test_subclassmeta_form(self):
|
||||
class SomeCategoryForm(forms.ModelForm):
|
||||
checkbox = forms.BooleanField()
|
||||
checkbox = forms.BooleanField()
|
||||
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = '__all__'
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = '__all__'
|
||||
|
||||
class SubclassMeta(SomeCategoryForm):
|
||||
""" We can also subclass the Meta inner class to change the fields
|
||||
|
|
|
@ -19,7 +19,7 @@ class Article(models.Model):
|
|||
pub_date = models.DateTimeField()
|
||||
|
||||
class Meta:
|
||||
ordering = ('pub_date',)
|
||||
ordering = ('pub_date',)
|
||||
|
||||
def __str__(self):
|
||||
return self.headline
|
||||
|
|
|
@ -29,7 +29,7 @@ class FavoriteAuthors(models.Model):
|
|||
likes_author = models.ForeignKey(Author, to_field='name', related_name='likes_me')
|
||||
|
||||
class Meta:
|
||||
ordering = ['id']
|
||||
ordering = ['id']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
|
|
@ -355,7 +355,7 @@ class ObjectC(models.Model):
|
|||
objectb = models.ForeignKey(ObjectB)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
return self.name
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SimpleCategory(models.Model):
|
||||
|
|
|
@ -21,8 +21,9 @@ class Thing(models.Model):
|
|||
having = models.CharField(max_length=1)
|
||||
where = models.DateField(max_length=1)
|
||||
has_hyphen = models.CharField(max_length=1, db_column='has-hyphen')
|
||||
|
||||
class Meta:
|
||||
db_table = 'select'
|
||||
db_table = 'select'
|
||||
|
||||
def __str__(self):
|
||||
return self.when
|
||||
|
|
|
@ -19,7 +19,7 @@ class Category(models.Model):
|
|||
name = models.CharField(max_length=20)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
ordering = ('name',)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -44,7 +44,7 @@ class Article(models.Model):
|
|||
categories = models.ManyToManyField(Category)
|
||||
|
||||
class Meta:
|
||||
ordering = ('pub_date',)
|
||||
ordering = ('pub_date',)
|
||||
|
||||
def __str__(self):
|
||||
return self.headline
|
||||
|
@ -77,7 +77,7 @@ class Movie(models.Model):
|
|||
price = models.DecimalField(max_digits=6, decimal_places=2, default=Decimal('0.00'))
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
ordering = ('title',)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
|
Loading…
Reference in New Issue