diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2017-01-23 16:13:49 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-01-23 19:14:43 -0500 |
| commit | 783afda70ad55e39f268c953997ec0f92ba37aee (patch) | |
| tree | 052f657bf515c8282e96de1fe96d87df978cf97e /tests/admin_views | |
| parent | 706b30fc37f59f2211b78ceff24c4fcb680e8a5d (diff) | |
[1.11.x] Replaced dict() usage with dict literals.
Literals are faster and more idiomatic.
Backport of 0d74c41981687598d3fa0a7eb9712ce4c387ca19 from master
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/tests.py | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index c952a9ebf2..4f281bd01a 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -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']: |
