Fixed #21288 -- Fixed E126 pep8 warnings
This commit is contained in:
parent
a3690168cb
commit
b289fcf1bf
|
@ -150,8 +150,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
|
||||||
# rendered output. formfield can be None if it came from a
|
# rendered output. formfield can be None if it came from a
|
||||||
# OneToOneField with parent_link=True or a M2M intermediary.
|
# OneToOneField with parent_link=True or a M2M intermediary.
|
||||||
if formfield and db_field.name not in self.raw_id_fields:
|
if formfield and db_field.name not in self.raw_id_fields:
|
||||||
related_modeladmin = self.admin_site._registry.get(
|
related_modeladmin = self.admin_site._registry.get(db_field.rel.to)
|
||||||
db_field.rel.to)
|
|
||||||
can_add_related = bool(related_modeladmin and
|
can_add_related = bool(related_modeladmin and
|
||||||
related_modeladmin.has_add_permission(request))
|
related_modeladmin.has_add_permission(request))
|
||||||
formfield.widget = widgets.RelatedFieldWidgetWrapper(
|
formfield.widget = widgets.RelatedFieldWidgetWrapper(
|
||||||
|
@ -1196,8 +1195,8 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
|
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
|
|
||||||
self.message_user(request, _(
|
self.message_user(request,
|
||||||
'The %(name)s "%(obj)s" was deleted successfully.') % {
|
_('The %(name)s "%(obj)s" was deleted successfully.') % {
|
||||||
'name': force_text(opts.verbose_name),
|
'name': force_text(opts.verbose_name),
|
||||||
'obj': force_text(obj_display)
|
'obj': force_text(obj_display)
|
||||||
}, messages.SUCCESS)
|
}, messages.SUCCESS)
|
||||||
|
@ -1313,8 +1312,8 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(opts.verbose_name), 'key': escape(object_id)})
|
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(opts.verbose_name), 'key': escape(object_id)})
|
||||||
|
|
||||||
if request.method == 'POST' and "_saveasnew" in request.POST:
|
if request.method == 'POST' and "_saveasnew" in request.POST:
|
||||||
return self.add_view(request, form_url=reverse('admin:%s_%s_add' %
|
return self.add_view(request, form_url=reverse('admin:%s_%s_add' % (
|
||||||
(opts.app_label, opts.model_name),
|
opts.app_label, opts.model_name),
|
||||||
current_app=self.admin_site.name))
|
current_app=self.admin_site.name))
|
||||||
|
|
||||||
ModelForm = self.get_form(request, obj)
|
ModelForm = self.get_form(request, obj)
|
||||||
|
|
|
@ -164,8 +164,7 @@ def result_headers(cl):
|
||||||
"url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),
|
"url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}),
|
||||||
"url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}),
|
"url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}),
|
||||||
"url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}),
|
"url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}),
|
||||||
"class_attrib": format_html(' class="{0}"', ' '.join(th_classes))
|
"class_attrib": format_html(' class="{0}"', ' '.join(th_classes)) if th_classes else '',
|
||||||
if th_classes else '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _boolean_icon(field_val):
|
def _boolean_icon(field_val):
|
||||||
|
@ -246,8 +245,7 @@ def items_for_result(cl, result, form):
|
||||||
link_or_text = format_html(
|
link_or_text = format_html(
|
||||||
'<a href="{0}"{1}>{2}</a>',
|
'<a href="{0}"{1}>{2}</a>',
|
||||||
url,
|
url,
|
||||||
format_html(' onclick="opener.dismissRelatedLookupPopup(window, '{0}'); return false;"', result_id)
|
format_html(' onclick="opener.dismissRelatedLookupPopup(window, '{0}'); return false;"', result_id) if cl.is_popup else '',
|
||||||
if cl.is_popup else '',
|
|
||||||
result_repr)
|
result_repr)
|
||||||
|
|
||||||
yield format_html('<{0}{1}>{2}</{3}>',
|
yield format_html('<{0}{1}>{2}</{3}>',
|
||||||
|
|
|
@ -33,8 +33,7 @@ def submit_row(context):
|
||||||
'show_delete_link': (not is_popup and context['has_delete_permission']
|
'show_delete_link': (not is_popup and context['has_delete_permission']
|
||||||
and change and context.get('show_delete', True)),
|
and change and context.get('show_delete', True)),
|
||||||
'show_save_as_new': not is_popup and change and save_as,
|
'show_save_as_new': not is_popup and change and save_as,
|
||||||
'show_save_and_add_another': context['has_add_permission'] and
|
'show_save_and_add_another': context['has_add_permission'] and not is_popup and (not save_as or context['add']),
|
||||||
not is_popup and (not save_as or context['add']),
|
|
||||||
'show_save_and_continue': not is_popup and context['has_change_permission'],
|
'show_save_and_continue': not is_popup and context['has_change_permission'],
|
||||||
'is_popup': is_popup,
|
'is_popup': is_popup,
|
||||||
'show_save': True,
|
'show_save': True,
|
||||||
|
|
|
@ -177,7 +177,8 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||||
# HTTP_HOST header isn't poisoned. This is done as a check when get_host()
|
# HTTP_HOST header isn't poisoned. This is done as a check when get_host()
|
||||||
# is invoked, but we check here as a practical consequence.
|
# is invoked, but we check here as a practical consequence.
|
||||||
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
|
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
|
||||||
response = self.client.post('/password_reset/',
|
response = self.client.post(
|
||||||
|
'/password_reset/',
|
||||||
{'email': 'staffmember@example.com'},
|
{'email': 'staffmember@example.com'},
|
||||||
HTTP_HOST='www.example:dr.frankenstein@evil.tld'
|
HTTP_HOST='www.example:dr.frankenstein@evil.tld'
|
||||||
)
|
)
|
||||||
|
@ -190,7 +191,8 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||||
def test_poisoned_http_host_admin_site(self):
|
def test_poisoned_http_host_admin_site(self):
|
||||||
"Poisoned HTTP_HOST headers can't be used for reset emails on admin views"
|
"Poisoned HTTP_HOST headers can't be used for reset emails on admin views"
|
||||||
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
|
with patch_logger('django.security.DisallowedHost', 'error') as logger_calls:
|
||||||
response = self.client.post('/admin_password_reset/',
|
response = self.client.post(
|
||||||
|
'/admin_password_reset/',
|
||||||
{'email': 'staffmember@example.com'},
|
{'email': 'staffmember@example.com'},
|
||||||
HTTP_HOST='www.example:dr.frankenstein@evil.tld'
|
HTTP_HOST='www.example:dr.frankenstein@evil.tld'
|
||||||
)
|
)
|
||||||
|
|
|
@ -240,11 +240,9 @@ class GenericRelation(ForeignObject):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.rel.to._base_manager.db_manager(using).filter(**{
|
return self.rel.to._base_manager.db_manager(using).filter(**{
|
||||||
"%s__pk" % self.content_type_field_name:
|
"%s__pk" % self.content_type_field_name: ContentType.objects.db_manager(using).get_for_model(
|
||||||
ContentType.objects.db_manager(using).get_for_model(
|
|
||||||
self.model, for_concrete_model=self.for_concrete_model).pk,
|
self.model, for_concrete_model=self.for_concrete_model).pk,
|
||||||
"%s__in" % self.object_id_field_name:
|
"%s__in" % self.object_id_field_name: [obj.pk for obj in objs]
|
||||||
[obj.pk for obj in objs]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -352,8 +350,7 @@ def create_generic_related_manager(superclass):
|
||||||
db = self._db or router.db_for_read(self.model, instance=instances[0])
|
db = self._db or router.db_for_read(self.model, instance=instances[0])
|
||||||
query = {
|
query = {
|
||||||
'%s__pk' % self.content_type_field_name: self.content_type.id,
|
'%s__pk' % self.content_type_field_name: self.content_type.id,
|
||||||
'%s__in' % self.object_id_field_name:
|
'%s__in' % self.object_id_field_name: set(obj._get_pk_val() for obj in instances)
|
||||||
set(obj._get_pk_val() for obj in instances)
|
|
||||||
}
|
}
|
||||||
qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
|
qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
|
||||||
# We (possibly) need to convert object IDs to the type of the
|
# We (possibly) need to convert object IDs to the type of the
|
||||||
|
|
|
@ -134,7 +134,8 @@ class GEOSMutationTest(unittest.TestCase):
|
||||||
# _set_list
|
# _set_list
|
||||||
pg._set_list(2, (((1,2),(10,0),(12,9),(-1,15),(1,2)),
|
pg._set_list(2, (((1,2),(10,0),(12,9),(-1,15),(1,2)),
|
||||||
((4,2),(5,2),(5,3),(4,2))))
|
((4,2),(5,2),(5,3),(4,2))))
|
||||||
self.assertEqual(pg.coords,
|
self.assertEqual(
|
||||||
|
pg.coords,
|
||||||
(((1.0,2.0),(10.0,0.0),(12.0,9.0),(-1.0,15.0),(1.0,2.0)),
|
(((1.0,2.0),(10.0,0.0),(12.0,9.0),(-1.0,15.0),(1.0,2.0)),
|
||||||
((4.0,2.0),(5.0,2.0),(5.0,3.0),(4.0,2.0))),
|
((4.0,2.0),(5.0,2.0),(5.0,3.0),(4.0,2.0))),
|
||||||
'Polygon _set_list')
|
'Polygon _set_list')
|
||||||
|
|
|
@ -279,8 +279,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,16 +107,20 @@ class ModelBase(type):
|
||||||
|
|
||||||
new_class.add_to_class('_meta', Options(meta, **kwargs))
|
new_class.add_to_class('_meta', Options(meta, **kwargs))
|
||||||
if not abstract:
|
if not abstract:
|
||||||
new_class.add_to_class('DoesNotExist', subclass_exception(str('DoesNotExist'),
|
new_class.add_to_class(
|
||||||
tuple(x.DoesNotExist
|
'DoesNotExist',
|
||||||
for x in parents if hasattr(x, '_meta') and not x._meta.abstract)
|
subclass_exception(
|
||||||
or (ObjectDoesNotExist,),
|
str('DoesNotExist'),
|
||||||
module, attached_to=new_class))
|
tuple(x.DoesNotExist for x in parents if hasattr(x, '_meta') and not x._meta.abstract) or (ObjectDoesNotExist,),
|
||||||
new_class.add_to_class('MultipleObjectsReturned', subclass_exception(str('MultipleObjectsReturned'),
|
module,
|
||||||
tuple(x.MultipleObjectsReturned
|
attached_to=new_class))
|
||||||
for x in parents if hasattr(x, '_meta') and not x._meta.abstract)
|
new_class.add_to_class(
|
||||||
or (MultipleObjectsReturned,),
|
'MultipleObjectsReturned',
|
||||||
module, attached_to=new_class))
|
subclass_exception(
|
||||||
|
str('MultipleObjectsReturned'),
|
||||||
|
tuple(x.MultipleObjectsReturned for x in parents if hasattr(x, '_meta') and not x._meta.abstract) or (MultipleObjectsReturned,),
|
||||||
|
module,
|
||||||
|
attached_to=new_class))
|
||||||
if base_meta and not base_meta.abstract:
|
if base_meta and not base_meta.abstract:
|
||||||
# Non-abstract child classes inherit some attributes from their
|
# Non-abstract child classes inherit some attributes from their
|
||||||
# non-abstract parent (unless an ABC comes before it in the
|
# non-abstract parent (unless an ABC comes before it in the
|
||||||
|
@ -565,9 +569,9 @@ class Model(six.with_metaclass(ModelBase)):
|
||||||
field_names.add(field.attname)
|
field_names.add(field.attname)
|
||||||
deferred_fields = [
|
deferred_fields = [
|
||||||
f.attname for f in self._meta.fields
|
f.attname for f in self._meta.fields
|
||||||
if f.attname not in self.__dict__
|
if (f.attname not in self.__dict__ and
|
||||||
and isinstance(self.__class__.__dict__[f.attname],
|
isinstance(self.__class__.__dict__[f.attname], DeferredAttribute))
|
||||||
DeferredAttribute)]
|
]
|
||||||
|
|
||||||
loaded_fields = field_names.difference(deferred_fields)
|
loaded_fields = field_names.difference(deferred_fields)
|
||||||
if loaded_fields:
|
if loaded_fields:
|
||||||
|
|
|
@ -1042,8 +1042,8 @@ class ModelChoiceIterator(object):
|
||||||
yield self.choice(obj)
|
yield self.choice(obj)
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.queryset) +\
|
return (len(self.queryset) +
|
||||||
(1 if self.field.empty_label is not None else 0)
|
(1 if self.field.empty_label is not None else 0))
|
||||||
|
|
||||||
def choice(self, obj):
|
def choice(self, obj):
|
||||||
return (self.field.prepare_value(obj), self.field.label_from_instance(obj))
|
return (self.field.prepare_value(obj), self.field.label_from_instance(obj))
|
||||||
|
|
|
@ -143,13 +143,13 @@ class JsLexer(Lexer):
|
||||||
]
|
]
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'div': # slash will mean division
|
# slash will mean division
|
||||||
both_before + [
|
'div': both_before + [
|
||||||
Tok("punct", literals("/= /"), next='reg'),
|
Tok("punct", literals("/= /"), next='reg'),
|
||||||
] + both_after,
|
] + both_after,
|
||||||
|
|
||||||
'reg': # slash will mean regex
|
# slash will mean regex
|
||||||
both_before + [
|
'reg': both_before + [
|
||||||
Tok("regex",
|
Tok("regex",
|
||||||
r"""
|
r"""
|
||||||
/ # opening slash
|
/ # opening slash
|
||||||
|
|
|
@ -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=E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,F401,F403,W601
|
ignore=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,F401,F403,W601
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
license-file = LICENSE
|
license-file = LICENSE
|
||||||
|
|
|
@ -171,8 +171,7 @@ class Fabric(models.Model):
|
||||||
('Textured', (
|
('Textured', (
|
||||||
('x', 'Horizontal'),
|
('x', 'Horizontal'),
|
||||||
('y', 'Vertical'),
|
('y', 'Vertical'),
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
('plain', 'Smooth'),
|
('plain', 'Smooth'),
|
||||||
)
|
)
|
||||||
surface = models.CharField(max_length=20, choices=NG_CHOICES)
|
surface = models.CharField(max_length=20, choices=NG_CHOICES)
|
||||||
|
|
|
@ -425,12 +425,10 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||||
test=lambda obj, value: obj.chap.book.name == value),
|
test=lambda obj, value: obj.chap.book.name == value),
|
||||||
'chap__book__promo__id__exact': dict(
|
'chap__book__promo__id__exact': dict(
|
||||||
values=[p.id for p in Promo.objects.all()],
|
values=[p.id for p in Promo.objects.all()],
|
||||||
test=lambda obj, value:
|
test=lambda obj, value: obj.chap.book.promo_set.filter(id=value).exists()),
|
||||||
obj.chap.book.promo_set.filter(id=value).exists()),
|
|
||||||
'chap__book__promo__name': dict(
|
'chap__book__promo__name': dict(
|
||||||
values=[p.name for p in Promo.objects.all()],
|
values=[p.name for p in Promo.objects.all()],
|
||||||
test=lambda obj, value:
|
test=lambda obj, value: obj.chap.book.promo_set.filter(name=value).exists()),
|
||||||
obj.chap.book.promo_set.filter(name=value).exists()),
|
|
||||||
}
|
}
|
||||||
for filter_path, params in filters.items():
|
for filter_path, params in filters.items():
|
||||||
for value in params['values']:
|
for value in params['values']:
|
||||||
|
|
|
@ -54,8 +54,12 @@ 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),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Return the formfield so that other tests can continue
|
# Return the formfield so that other tests can continue
|
||||||
|
|
|
@ -605,8 +605,7 @@ class ModelTest(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
dicts = Article.objects.filter(
|
dicts = Article.objects.filter(
|
||||||
pub_date__year=2008).extra(
|
pub_date__year=2008).extra(select={'dashed-value': '1'}
|
||||||
select={'dashed-value': '1'}
|
|
||||||
).values('headline', 'dashed-value')
|
).values('headline', 'dashed-value')
|
||||||
self.assertEqual([sorted(d.items()) for d in dicts],
|
self.assertEqual([sorted(d.items()) for d in dicts],
|
||||||
[[('dashed-value', 1), ('headline', 'Article 11')], [('dashed-value', 1), ('headline', 'Article 12')]])
|
[[('dashed-value', 1), ('headline', 'Article 11')], [('dashed-value', 1), ('headline', 'Article 12')]])
|
||||||
|
@ -629,8 +628,7 @@ class ModelTest(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
articles = Article.objects.filter(
|
articles = Article.objects.filter(
|
||||||
pub_date__year=2008).extra(
|
pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'})
|
||||||
select={'dashed-value': '1', 'undashedvalue': '2'})
|
|
||||||
self.assertEqual(articles[0].undashedvalue, 2)
|
self.assertEqual(articles[0].undashedvalue, 2)
|
||||||
|
|
||||||
def test_create_relation_with_ugettext_lazy(self):
|
def test_create_relation_with_ugettext_lazy(self):
|
||||||
|
|
|
@ -51,8 +51,7 @@ 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?
|
||||||
|
|
|
@ -312,8 +312,7 @@ class ExtraRegressTests(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
TestObject.objects.filter(pk=obj.pk) |
|
TestObject.objects.filter(pk=obj.pk) | TestObject.objects.extra(where=["id > %s"], params=[obj.pk]),
|
||||||
TestObject.objects.extra(where=["id > %s"], params=[obj.pk]),
|
|
||||||
['<TestObject: TestObject: first,second,third>']
|
['<TestObject: TestObject: first,second,third>']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -377,8 +377,7 @@ class FileUploadTests(TestCase):
|
||||||
vars = {'boundary': 'oUrBoUnDaRyStRiNg'}
|
vars = {'boundary': 'oUrBoUnDaRyStRiNg'}
|
||||||
post_data = [
|
post_data = [
|
||||||
'--%(boundary)s',
|
'--%(boundary)s',
|
||||||
'Content-Disposition: form-data; name="file_field"; '
|
'Content-Disposition: form-data; name="file_field"; filename="MiXeD_cAsE.txt"',
|
||||||
'filename="MiXeD_cAsE.txt"',
|
|
||||||
'Content-Type: application/octet-stream',
|
'Content-Type: application/octet-stream',
|
||||||
'',
|
'',
|
||||||
'file contents\n'
|
'file contents\n'
|
||||||
|
|
|
@ -123,8 +123,8 @@ class DerivedM(BaseM):
|
||||||
derived_name = models.CharField(max_length=100)
|
derived_name = models.CharField(max_length=100)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "PK = %d, base_name = %s, derived_name = %s" \
|
return "PK = %d, base_name = %s, derived_name = %s" % (
|
||||||
% (self.customPK, self.base_name, self.derived_name)
|
self.customPK, self.base_name, self.derived_name)
|
||||||
|
|
||||||
class AuditBase(models.Model):
|
class AuditBase(models.Model):
|
||||||
planned_date = models.DateField()
|
planned_date = models.DateField()
|
||||||
|
|
|
@ -556,10 +556,8 @@ def naturalKeyTest(format, self):
|
||||||
self.assertEqual(books[1].object.pk, None)
|
self.assertEqual(books[1].object.pk, None)
|
||||||
|
|
||||||
|
|
||||||
for format in [
|
for format in [f for f in serializers.get_serializer_formats()
|
||||||
f for f in serializers.get_serializer_formats()
|
if not isinstance(serializers.get_serializer(f), serializers.BadSerializer)]:
|
||||||
if not isinstance(serializers.get_serializer(f), serializers.BadSerializer)
|
|
||||||
]:
|
|
||||||
setattr(SerializerTests, 'test_' + format + '_serializer', curry(serializerTest, format))
|
setattr(SerializerTests, 'test_' + format + '_serializer', curry(serializerTest, format))
|
||||||
setattr(SerializerTests, 'test_' + format + '_natural_key_serializer', curry(naturalKeySerializerTest, format))
|
setattr(SerializerTests, 'test_' + format + '_natural_key_serializer', curry(naturalKeySerializerTest, format))
|
||||||
setattr(SerializerTests, 'test_' + format + '_serializer_fields', curry(fieldsTest, format))
|
setattr(SerializerTests, 'test_' + format + '_serializer_fields', curry(fieldsTest, format))
|
||||||
|
|
|
@ -223,24 +223,30 @@ class LegacyDatabaseTests(TestCase):
|
||||||
def test_query_datetimes(self):
|
def test_query_datetimes(self):
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0))
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0))
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'year'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'year'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'month'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'month'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'day'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'day'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'hour'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'hour'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 0, 0),
|
[datetime.datetime(2011, 1, 1, 1, 0, 0),
|
||||||
datetime.datetime(2011, 1, 1, 4, 0, 0)],
|
datetime.datetime(2011, 1, 1, 4, 0, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'minute'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'minute'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 30, 0),
|
[datetime.datetime(2011, 1, 1, 1, 30, 0),
|
||||||
datetime.datetime(2011, 1, 1, 4, 30, 0)],
|
datetime.datetime(2011, 1, 1, 4, 30, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'second'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'second'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 30, 0),
|
[datetime.datetime(2011, 1, 1, 1, 30, 0),
|
||||||
datetime.datetime(2011, 1, 1, 4, 30, 0)],
|
datetime.datetime(2011, 1, 1, 4, 30, 0)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
|
@ -472,24 +478,30 @@ class NewDatabaseTests(TestCase):
|
||||||
def test_query_datetimes(self):
|
def test_query_datetimes(self):
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'year'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'year'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'month'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'month'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'day'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'day'),
|
||||||
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
[datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'hour'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'hour'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=EAT),
|
[datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=EAT),
|
||||||
datetime.datetime(2011, 1, 1, 4, 0, 0, tzinfo=EAT)],
|
datetime.datetime(2011, 1, 1, 4, 0, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'minute'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'minute'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
|
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
|
||||||
datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
|
datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'second'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'second'),
|
||||||
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
|
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
|
||||||
datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
|
datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
|
@ -499,27 +511,33 @@ class NewDatabaseTests(TestCase):
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
|
||||||
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
|
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
|
||||||
with timezone.override(UTC):
|
with timezone.override(UTC):
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'year'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'year'),
|
||||||
[datetime.datetime(2010, 1, 1, 0, 0, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 1, 1, 0, 0, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'month'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'month'),
|
||||||
[datetime.datetime(2010, 12, 1, 0, 0, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 12, 1, 0, 0, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'day'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'day'),
|
||||||
[datetime.datetime(2010, 12, 31, 0, 0, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 12, 31, 0, 0, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'hour'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'hour'),
|
||||||
[datetime.datetime(2010, 12, 31, 22, 0, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 12, 31, 22, 0, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'minute'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'minute'),
|
||||||
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
self.assertQuerysetEqual(Event.objects.datetimes('dt', 'second'),
|
self.assertQuerysetEqual(
|
||||||
|
Event.objects.datetimes('dt', 'second'),
|
||||||
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
|
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
|
||||||
datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
|
datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
|
|
Loading…
Reference in New Issue