[1.11.x] Replaced dict() usage with dict literals.
Literals are faster and more idiomatic.
Backport of 0d74c41981
from master
This commit is contained in:
parent
706b30fc37
commit
783afda70a
|
@ -608,16 +608,16 @@ class ChoiceWidget(Widget):
|
|||
option_attrs.update(self.checked_attribute)
|
||||
if 'id' in option_attrs:
|
||||
option_attrs['id'] = self.id_for_label(option_attrs['id'], index)
|
||||
return dict(
|
||||
name=name,
|
||||
value=value,
|
||||
label=label,
|
||||
selected=selected,
|
||||
index=index,
|
||||
attrs=option_attrs,
|
||||
type=self.input_type,
|
||||
template_name=self.option_template_name,
|
||||
)
|
||||
return {
|
||||
'name': name,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'selected': selected,
|
||||
'index': index,
|
||||
'attrs': option_attrs,
|
||||
'type': self.input_type,
|
||||
'template_name': self.option_template_name,
|
||||
}
|
||||
|
||||
def get_context(self, name, value, attrs=None):
|
||||
context = super(ChoiceWidget, self).get_context(name, value, attrs)
|
||||
|
|
|
@ -550,11 +550,11 @@ class DiscoverRunner(object):
|
|||
return DebugSQLTextTestResult if self.debug_sql else None
|
||||
|
||||
def get_test_runner_kwargs(self):
|
||||
return dict(
|
||||
failfast=self.failfast,
|
||||
resultclass=self.get_resultclass(),
|
||||
verbosity=self.verbosity,
|
||||
)
|
||||
return {
|
||||
'failfast': self.failfast,
|
||||
'resultclass': self.get_resultclass(),
|
||||
'verbosity': self.verbosity,
|
||||
}
|
||||
|
||||
def run_checks(self):
|
||||
# Checks are run after database creation since some checks require
|
||||
|
|
|
@ -588,24 +588,30 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
|||
response = self.client.get(changelist_url)
|
||||
self.assertContains(response, '<div id="changelist-filter">')
|
||||
filters = {
|
||||
'chap__id__exact': dict(
|
||||
values=[c.id for c in Chapter.objects.all()],
|
||||
test=lambda obj, value: obj.chap.id == value),
|
||||
'chap__title': dict(
|
||||
values=[c.title for c in Chapter.objects.all()],
|
||||
test=lambda obj, value: obj.chap.title == value),
|
||||
'chap__book__id__exact': dict(
|
||||
values=[b.id for b in Book.objects.all()],
|
||||
test=lambda obj, value: obj.chap.book.id == value),
|
||||
'chap__book__name': dict(
|
||||
values=[b.name for b in Book.objects.all()],
|
||||
test=lambda obj, value: obj.chap.book.name == value),
|
||||
'chap__book__promo__id__exact': dict(
|
||||
values=[p.id for p in Promo.objects.all()],
|
||||
test=lambda obj, value: obj.chap.book.promo_set.filter(id=value).exists()),
|
||||
'chap__book__promo__name': dict(
|
||||
values=[p.name for p in Promo.objects.all()],
|
||||
test=lambda obj, value: obj.chap.book.promo_set.filter(name=value).exists()),
|
||||
'chap__id__exact': {
|
||||
'values': [c.id for c in Chapter.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.id == value,
|
||||
},
|
||||
'chap__title': {
|
||||
'values': [c.title for c in Chapter.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.title == value,
|
||||
},
|
||||
'chap__book__id__exact': {
|
||||
'values': [b.id for b in Book.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.book.id == value,
|
||||
},
|
||||
'chap__book__name': {
|
||||
'values': [b.name for b in Book.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.book.name == value,
|
||||
},
|
||||
'chap__book__promo__id__exact': {
|
||||
'values': [p.id for p in Promo.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.book.promo_set.filter(id=value).exists(),
|
||||
},
|
||||
'chap__book__promo__name': {
|
||||
'values': [p.name for p in Promo.objects.all()],
|
||||
'test': lambda obj, value: obj.chap.book.promo_set.filter(name=value).exists(),
|
||||
},
|
||||
}
|
||||
for filter_path, params in filters.items():
|
||||
for value in params['values']:
|
||||
|
|
|
@ -141,13 +141,13 @@ class I18NTests(TestCase):
|
|||
def test_setlang_cookie(self):
|
||||
# we force saving language to a cookie rather than a session
|
||||
# by excluding session middleware and those which do require it
|
||||
test_settings = dict(
|
||||
MIDDLEWARE=['django.middleware.common.CommonMiddleware'],
|
||||
LANGUAGE_COOKIE_NAME='mylanguage',
|
||||
LANGUAGE_COOKIE_AGE=3600 * 7 * 2,
|
||||
LANGUAGE_COOKIE_DOMAIN='.example.com',
|
||||
LANGUAGE_COOKIE_PATH='/test/',
|
||||
)
|
||||
test_settings = {
|
||||
'MIDDLEWARE': ['django.middleware.common.CommonMiddleware'],
|
||||
'LANGUAGE_COOKIE_NAME': 'mylanguage',
|
||||
'LANGUAGE_COOKIE_AGE': 3600 * 7 * 2,
|
||||
'LANGUAGE_COOKIE_DOMAIN': '.example.com',
|
||||
'LANGUAGE_COOKIE_PATH': '/test/',
|
||||
}
|
||||
with self.settings(**test_settings):
|
||||
post_data = dict(language='pl', next='/views/')
|
||||
response = self.client.post('/i18n/setlang/', data=post_data)
|
||||
|
|
Loading…
Reference in New Issue