diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-26 18:27:42 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-26 18:27:42 -0700 |
| commit | b35ff0d9208c426cc0f67c65d724972974734f57 (patch) | |
| tree | 90d724e0b7a367d485712d79bfd4027717c8c08b /tests | |
| parent | 3351e94ffa37d3824a49b687125ee4a430b69bbe (diff) | |
Fixed all the E203 violations
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_views/admin.py | 8 | ||||
| -rw-r--r-- | tests/aggregation_regress/tests.py | 16 | ||||
| -rw-r--r-- | tests/cache/tests.py | 52 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 10 | ||||
| -rw-r--r-- | tests/model_forms/tests.py | 6 | ||||
| -rw-r--r-- | tests/serializers/tests.py | 2 | ||||
| -rw-r--r-- | tests/template_tests/filters.py | 52 | ||||
| -rw-r--r-- | tests/template_tests/templatetags/custom.py | 20 | ||||
| -rw-r--r-- | tests/template_tests/tests.py | 12 | ||||
| -rw-r--r-- | tests/test_client/views.py | 4 | ||||
| -rw-r--r-- | tests/test_utils/tests.py | 2 |
11 files changed, 92 insertions, 92 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index af197498ce..7dd6c91e71 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -45,7 +45,7 @@ callable_year.admin_order_field = 'date' class ArticleInline(admin.TabularInline): model = Article prepopulated_fields = { - 'title' : ('content',) + 'title': ('content',) } fieldsets = ( ('Some fields', { @@ -382,7 +382,7 @@ class SubPostInline(admin.TabularInline): model = PrePopulatedSubPost prepopulated_fields = { - 'subslug' : ('subtitle',) + 'subslug': ('subtitle',) } def get_readonly_fields(self, request, obj=None): @@ -399,7 +399,7 @@ class SubPostInline(admin.TabularInline): class PrePopulatedPostAdmin(admin.ModelAdmin): list_display = ['title', 'slug'] prepopulated_fields = { - 'slug' : ('title',) + 'slug': ('title',) } inlines = [SubPostInline] @@ -569,7 +569,7 @@ class AlbumAdmin(admin.ModelAdmin): class PrePopulatedPostLargeSlugAdmin(admin.ModelAdmin): prepopulated_fields = { - 'slug' : ('title',) + 'slug': ('title',) } diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 2bc907662e..8e192bd082 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -113,7 +113,7 @@ class AggregationTests(TestCase): # Aggregate overrides extra selected column self.assertEqual( - Book.objects.extra(select={'price_per_page' : 'price / pages'}).aggregate(Sum('pages')), + Book.objects.extra(select={'price_per_page': 'price / pages'}).aggregate(Sum('pages')), {'pages__sum': 3703} ) @@ -136,7 +136,7 @@ class AggregationTests(TestCase): self.assertTrue(obj.manufacture_cost == 11.545 or obj.manufacture_cost == Decimal('11.545')) # Order of the annotate/extra in the query doesn't matter - obj = Book.objects.extra(select={'manufacture_cost' : 'price * .5'}).annotate(mean_auth_age=Avg('authors__age')).get(pk=2) + obj = Book.objects.extra(select={'manufacture_cost': 'price * .5'}).annotate(mean_auth_age=Avg('authors__age')).get(pk=2) self.assertObjectAttrs(obj, contact_id=3, id=2, @@ -153,7 +153,7 @@ class AggregationTests(TestCase): self.assertTrue(obj.manufacture_cost == 11.545 or obj.manufacture_cost == Decimal('11.545')) # Values queries can be combined with annotate and extra - obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost' : 'price * .5'}).values().get(pk=2) + obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost': 'price * .5'}).values().get(pk=2) manufacture_cost = obj['manufacture_cost'] self.assertTrue(manufacture_cost == 11.545 or manufacture_cost == Decimal('11.545')) del obj['manufacture_cost'] @@ -172,7 +172,7 @@ class AggregationTests(TestCase): # The order of the (empty) values, annotate and extra clauses doesn't # matter - obj = Book.objects.values().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost' : 'price * .5'}).get(pk=2) + obj = Book.objects.values().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost': 'price * .5'}).get(pk=2) manufacture_cost = obj['manufacture_cost'] self.assertTrue(manufacture_cost == 11.545 or manufacture_cost == Decimal('11.545')) del obj['manufacture_cost'] @@ -191,12 +191,12 @@ class AggregationTests(TestCase): # If the annotation precedes the values clause, it won't be included # unless it is explicitly named - obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).values('name').get(pk=1) + obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page': 'price / pages'}).values('name').get(pk=1) self.assertEqual(obj, { "name": 'The Definitive Guide to Django: Web Development Done Right', }) - obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).values('name', 'mean_auth_age').get(pk=1) + obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page': 'price / pages'}).values('name', 'mean_auth_age').get(pk=1) self.assertEqual(obj, { 'mean_auth_age': 34.5, 'name': 'The Definitive Guide to Django: Web Development Done Right', @@ -214,7 +214,7 @@ class AggregationTests(TestCase): # The annotations are added to values output if values() precedes # annotate() - obj = Book.objects.values('name').annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).get(pk=1) + obj = Book.objects.values('name').annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page': 'price / pages'}).get(pk=1) self.assertEqual(obj, { 'mean_auth_age': 34.5, 'name': 'The Definitive Guide to Django: Web Development Done Right', @@ -575,7 +575,7 @@ class AggregationTests(TestCase): # Regression for #10290 - extra selects with parameters can be used for # grouping. - qs = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'sheets' : '(pages + %s) / %s'}, select_params=[1, 2]).order_by('sheets').values('sheets') + qs = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'sheets': '(pages + %s) / %s'}, select_params=[1, 2]).order_by('sheets').values('sheets') self.assertQuerysetEqual( qs, [ 150, diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 02e7e54db1..0c6ae91553 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -119,13 +119,13 @@ class DummyCacheTests(unittest.TestCase): def test_data_types(self): "All data types are ignored equally by the dummy cache" stuff = { - 'string' : 'this is a string', - 'int' : 42, - 'list' : [1, 2, 3, 4], - 'tuple' : (1, 2, 3, 4), - 'dict' : {'A': 1, 'B' : 2}, - 'function' : f, - 'class' : C, + 'string': 'this is a string', + 'int': 42, + 'list': [1, 2, 3, 4], + 'tuple': (1, 2, 3, 4), + 'dict': {'A': 1, 'B': 2}, + 'function': f, + 'class': C, } self.cache.set("stuff", stuff) self.assertEqual(self.cache.get("stuff"), None) @@ -149,7 +149,7 @@ class DummyCacheTests(unittest.TestCase): 'ascii': 'ascii_value', 'unicode_ascii': 'Iñtërnâtiônàlizætiøn1', 'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2', - 'ascii2': {'x' : 1} + 'ascii2': {'x': 1} } for (key, value) in stuff.items(): self.cache.set(key, value) @@ -231,8 +231,8 @@ class BaseCacheTests(object): self.cache.set('b', 'b') self.cache.set('c', 'c') self.cache.set('d', 'd') - self.assertEqual(self.cache.get_many(['a', 'c', 'd']), {'a' : 'a', 'c' : 'c', 'd' : 'd'}) - self.assertEqual(self.cache.get_many(['a', 'b', 'e']), {'a' : 'a', 'b' : 'b'}) + self.assertEqual(self.cache.get_many(['a', 'c', 'd']), {'a': 'a', 'c': 'c', 'd': 'd'}) + self.assertEqual(self.cache.get_many(['a', 'b', 'e']), {'a': 'a', 'b': 'b'}) def test_delete(self): # Cache keys can be deleted @@ -282,13 +282,13 @@ class BaseCacheTests(object): def test_data_types(self): # Many different data types can be cached stuff = { - 'string' : 'this is a string', - 'int' : 42, - 'list' : [1, 2, 3, 4], - 'tuple' : (1, 2, 3, 4), - 'dict' : {'A': 1, 'B' : 2}, - 'function' : f, - 'class' : C, + 'string': 'this is a string', + 'int': 42, + 'list': [1, 2, 3, 4], + 'tuple': (1, 2, 3, 4), + 'dict': {'A': 1, 'B': 2}, + 'function': f, + 'class': C, } self.cache.set("stuff", stuff) self.assertEqual(self.cache.get("stuff"), stuff) @@ -353,7 +353,7 @@ class BaseCacheTests(object): 'ascii': 'ascii_value', 'unicode_ascii': 'Iñtërnâtiônàlizætiøn1', 'Iñtërnâtiônàlizætiøn': 'Iñtërnâtiônàlizætiøn2', - 'ascii2': {'x' : 1} + 'ascii2': {'x': 1} } # Test `set` for (key, value) in stuff.items(): @@ -1221,16 +1221,16 @@ class CacheUtils(TestCase): def test_patch_cache_control(self): tests = ( # Initial Cache-Control, kwargs to patch_cache_control, expected Cache-Control parts - (None, {'private' : True}, set(['private'])), + (None, {'private': True}, set(['private'])), # Test whether private/public attributes are mutually exclusive - ('private', {'private' : True}, set(['private'])), - ('private', {'public' : True}, set(['public'])), - ('public', {'public' : True}, set(['public'])), - ('public', {'private' : True}, set(['private'])), - ('must-revalidate,max-age=60,private', {'public' : True}, set(['must-revalidate', 'max-age=60', 'public'])), - ('must-revalidate,max-age=60,public', {'private' : True}, set(['must-revalidate', 'max-age=60', 'private'])), - ('must-revalidate,max-age=60', {'public' : True}, set(['must-revalidate', 'max-age=60', 'public'])), + ('private', {'private': True}, set(['private'])), + ('private', {'public': True}, set(['public'])), + ('public', {'public': True}, set(['public'])), + ('public', {'private': True}, set(['private'])), + ('must-revalidate,max-age=60,private', {'public': True}, set(['must-revalidate', 'max-age=60', 'public'])), + ('must-revalidate,max-age=60,public', {'private': True}, set(['must-revalidate', 'max-age=60', 'private'])), + ('must-revalidate,max-age=60', {'public': True}, set(['must-revalidate', 'max-age=60', 'public'])), ) cc_delim_re = re.compile(r'\s*,\s*') diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 0f1b8882f3..aecf8f32d5 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -1793,17 +1793,17 @@ class FormsTestCase(TestCase): class NameForm(Form): name = NameField(validators=[bad_names]) - form = NameForm(data={'name' : ['bad', 'value']}) + form = NameForm(data={'name': ['bad', 'value']}) form.full_clean() self.assertFalse(form.is_valid()) self.assertEqual(form.errors, {'name': ['bad value not allowed']}) - form = NameForm(data={'name' : ['should be overly', 'long for the field names']}) + form = NameForm(data={'name': ['should be overly', 'long for the field names']}) self.assertFalse(form.is_valid()) self.assertEqual(form.errors, {'name': ['Ensure this value has at most 10 characters (it has 16).', 'Ensure this value has at most 10 characters (it has 24).']}) - form = NameForm(data={'name' : ['fname', 'lname']}) + form = NameForm(data={'name': ['fname', 'lname']}) self.assertTrue(form.is_valid()) - self.assertEqual(form.cleaned_data, {'name' : 'fname lname'}) + self.assertEqual(form.cleaned_data, {'name': 'fname lname'}) def test_multivalue_deep_copy(self): """ @@ -1912,7 +1912,7 @@ class FormsTestCase(TestCase): form = JSONForm(data={'json': '{}'}) form.full_clean() - self.assertEqual(form.cleaned_data, {'json' : {}}) + self.assertEqual(form.cleaned_data, {'json': {}}) def test_boundfield_label_tag(self): class SomeForm(Form): diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 0db4ad7567..2da852d11e 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1751,7 +1751,7 @@ class OldFormForXTests(TestCase): self.assertHTMLEqual(six.text_type(CustomFieldForExclusionForm()), '''<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" maxlength="10" /></td></tr>''') - def test_iterable_model_m2m(self) : + def test_iterable_model_m2m(self): colour = Colour.objects.create(name='Blue') form = ColourfulItemForm() self.maxDiff = 1024 @@ -1763,7 +1763,7 @@ class OldFormForXTests(TestCase): </select> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p>""" % {'blue_pk': colour.pk}) - def test_custom_error_messages(self) : + def test_custom_error_messages(self): data = {'name1': '@#$!!**@#$', 'name2': '@#$!!**@#$'} errors = CustomErrorMessageForm(data).errors self.assertHTMLEqual( @@ -1775,7 +1775,7 @@ class OldFormForXTests(TestCase): '<ul class="errorlist"><li>Model custom error message.</li></ul>' ) - def test_model_clean_error_messages(self) : + def test_model_clean_error_messages(self): data = {'name1': 'FORBIDDEN_VALUE', 'name2': 'ABC'} errors = CustomErrorMessageForm(data).errors self.assertHTMLEqual( diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index f76ba6e7ed..71f5c1802e 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -28,7 +28,7 @@ from .models import (Category, Author, Article, AuthorProfile, Actor, Movie, @override_settings( SERIALIZATION_MODULES = { - "json2" : "django.core.serializers.json", + "json2": "django.core.serializers.json", } ) class SerializerRegistrationTests(TestCase): diff --git a/tests/template_tests/filters.py b/tests/template_tests/filters.py index 9441a8c678..36a519fd90 100644 --- a/tests/template_tests/filters.py +++ b/tests/template_tests/filters.py @@ -38,16 +38,16 @@ def get_filter_tests(): # NOTE: \xa0 avoids wrapping between value and unit return { # Default compare with datetime.now() - 'filter-timesince01' : ('{{ a|timesince }}', {'a': datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1\xa0minute'), - 'filter-timesince02' : ('{{ a|timesince }}', {'a': datetime.now() - timedelta(days=1, minutes = 1)}, '1\xa0day'), - 'filter-timesince03' : ('{{ a|timesince }}', {'a': datetime.now() - timedelta(hours=1, minutes=25, seconds = 10)}, '1\xa0hour, 25\xa0minutes'), + 'filter-timesince01': ('{{ a|timesince }}', {'a': datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1\xa0minute'), + 'filter-timesince02': ('{{ a|timesince }}', {'a': datetime.now() - timedelta(days=1, minutes = 1)}, '1\xa0day'), + 'filter-timesince03': ('{{ a|timesince }}', {'a': datetime.now() - timedelta(hours=1, minutes=25, seconds = 10)}, '1\xa0hour, 25\xa0minutes'), # Compare to a given parameter - 'filter-timesince04' : ('{{ a|timesince:b }}', {'a': now - timedelta(days=2), 'b': now - timedelta(days=1)}, '1\xa0day'), - 'filter-timesince05' : ('{{ a|timesince:b }}', {'a': now - timedelta(days=2, minutes=1), 'b': now - timedelta(days=2)}, '1\xa0minute'), + 'filter-timesince04': ('{{ a|timesince:b }}', {'a': now - timedelta(days=2), 'b': now - timedelta(days=1)}, '1\xa0day'), + 'filter-timesince05': ('{{ a|timesince:b }}', {'a': now - timedelta(days=2, minutes=1), 'b': now - timedelta(days=2)}, '1\xa0minute'), # Check that timezone is respected - 'filter-timesince06' : ('{{ a|timesince:b }}', {'a': now_tz - timedelta(hours=8), 'b': now_tz}, '8\xa0hours'), + 'filter-timesince06': ('{{ a|timesince:b }}', {'a': now_tz - timedelta(hours=8), 'b': now_tz}, '8\xa0hours'), # Regression for #7443 'filter-timesince07': ('{{ earlier|timesince }}', {'earlier': now - timedelta(days=7)}, '1\xa0week'), @@ -57,25 +57,25 @@ def get_filter_tests(): # Ensures that differing timezones are calculated correctly # Tests trying to compare a timezone-aware 'now' to now aren't supported on no-tz-support systems (e.g Windows). - 'filter-timesince11' : ('{{ a|timesince }}', {'a': now}, '0\xa0minutes'), - 'filter-timesince12' : ('{{ a|timesince }}', {'a': now_tz}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), - 'filter-timesince13' : ('{{ a|timesince }}', {'a': now_tz_i}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), - 'filter-timesince14' : ('{{ a|timesince:b }}', {'a': now_tz, 'b': now_tz_i}, '0\xa0minutes'), - 'filter-timesince15' : ('{{ a|timesince:b }}', {'a': now, 'b': now_tz_i}, ''), - 'filter-timesince16' : ('{{ a|timesince:b }}', {'a': now_tz_i, 'b': now}, ''), + 'filter-timesince11': ('{{ a|timesince }}', {'a': now}, '0\xa0minutes'), + 'filter-timesince12': ('{{ a|timesince }}', {'a': now_tz}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), + 'filter-timesince13': ('{{ a|timesince }}', {'a': now_tz_i}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), + 'filter-timesince14': ('{{ a|timesince:b }}', {'a': now_tz, 'b': now_tz_i}, '0\xa0minutes'), + 'filter-timesince15': ('{{ a|timesince:b }}', {'a': now, 'b': now_tz_i}, ''), + 'filter-timesince16': ('{{ a|timesince:b }}', {'a': now_tz_i, 'b': now}, ''), # Regression for #9065 (two date objects). - 'filter-timesince17' : ('{{ a|timesince:b }}', {'a': today, 'b': today}, '0\xa0minutes'), - 'filter-timesince18' : ('{{ a|timesince:b }}', {'a': today, 'b': today + timedelta(hours=24)}, '1\xa0day'), + 'filter-timesince17': ('{{ a|timesince:b }}', {'a': today, 'b': today}, '0\xa0minutes'), + 'filter-timesince18': ('{{ a|timesince:b }}', {'a': today, 'b': today + timedelta(hours=24)}, '1\xa0day'), # Default compare with datetime.now() - 'filter-timeuntil01' : ('{{ a|timeuntil }}', {'a': datetime.now() + timedelta(minutes=2, seconds=10)}, '2\xa0minutes'), - 'filter-timeuntil02' : ('{{ a|timeuntil }}', {'a': (datetime.now() + timedelta(days=1, seconds=10))}, '1\xa0day'), - 'filter-timeuntil03' : ('{{ a|timeuntil }}', {'a': (datetime.now() + timedelta(hours=8, minutes=10, seconds = 10))}, '8\xa0hours, 10\xa0minutes'), + 'filter-timeuntil01': ('{{ a|timeuntil }}', {'a': datetime.now() + timedelta(minutes=2, seconds=10)}, '2\xa0minutes'), + 'filter-timeuntil02': ('{{ a|timeuntil }}', {'a': (datetime.now() + timedelta(days=1, seconds=10))}, '1\xa0day'), + 'filter-timeuntil03': ('{{ a|timeuntil }}', {'a': (datetime.now() + timedelta(hours=8, minutes=10, seconds = 10))}, '8\xa0hours, 10\xa0minutes'), # Compare to a given parameter - 'filter-timeuntil04' : ('{{ a|timeuntil:b }}', {'a': now - timedelta(days=1), 'b': now - timedelta(days=2)}, '1\xa0day'), - 'filter-timeuntil05' : ('{{ a|timeuntil:b }}', {'a': now - timedelta(days=2), 'b': now - timedelta(days=2, minutes=1)}, '1\xa0minute'), + 'filter-timeuntil04': ('{{ a|timeuntil:b }}', {'a': now - timedelta(days=1), 'b': now - timedelta(days=2)}, '1\xa0day'), + 'filter-timeuntil05': ('{{ a|timeuntil:b }}', {'a': now - timedelta(days=2), 'b': now - timedelta(days=2, minutes=1)}, '1\xa0minute'), # Regression for #7443 'filter-timeuntil06': ('{{ earlier|timeuntil }}', {'earlier': now - timedelta(days=7)}, '0\xa0minutes'), @@ -85,13 +85,13 @@ def get_filter_tests(): # Ensures that differing timezones are calculated correctly # Tests trying to compare a timezone-aware 'now' to now aren't supported on no-tz-support systems (e.g Windows). - 'filter-timeuntil10' : ('{{ a|timeuntil }}', {'a': now_tz}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), - 'filter-timeuntil11' : ('{{ a|timeuntil }}', {'a': now_tz_i}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), - 'filter-timeuntil12' : ('{{ a|timeuntil:b }}', {'a': now_tz_i, 'b': now_tz}, '0\xa0minutes'), + 'filter-timeuntil10': ('{{ a|timeuntil }}', {'a': now_tz}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), + 'filter-timeuntil11': ('{{ a|timeuntil }}', {'a': now_tz_i}, '0\xa0minutes') if TZ_SUPPORT else ('', {}, ''), + 'filter-timeuntil12': ('{{ a|timeuntil:b }}', {'a': now_tz_i, 'b': now_tz}, '0\xa0minutes'), # Regression for #9065 (two date objects). - 'filter-timeuntil13' : ('{{ a|timeuntil:b }}', {'a': today, 'b': today}, '0\xa0minutes'), - 'filter-timeuntil14' : ('{{ a|timeuntil:b }}', {'a': today, 'b': today - timedelta(hours=24)}, '1\xa0day'), + 'filter-timeuntil13': ('{{ a|timeuntil:b }}', {'a': today, 'b': today}, '0\xa0minutes'), + 'filter-timeuntil14': ('{{ a|timeuntil:b }}', {'a': today, 'b': today - timedelta(hours=24)}, '1\xa0day'), 'filter-addslash01': ("{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}{% endautoescape %}", {"a": "<a>'", "b": mark_safe("<a>'")}, r"<a>\' <a>\'"), 'filter-addslash02': ("{{ a|addslashes }} {{ b|addslashes }}", {"a": "<a>'", "b": mark_safe("<a>'")}, r"<a>\' <a>\'"), @@ -135,8 +135,8 @@ def get_filter_tests(): ". a<b. . a<b."), # Test the title filter - 'filter-title1' : ('{{ a|title }}', {'a' : 'JOE\'S CRAB SHACK'}, 'Joe's Crab Shack'), - 'filter-title2' : ('{{ a|title }}', {'a' : '555 WEST 53RD STREET'}, '555 West 53rd Street'), + 'filter-title1': ('{{ a|title }}', {'a': 'JOE\'S CRAB SHACK'}, 'Joe's Crab Shack'), + 'filter-title2': ('{{ a|title }}', {'a': '555 WEST 53RD STREET'}, '555 West 53rd Street'), 'filter-truncatewords01': ('{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}', {"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, "alpha & ... alpha & ..."), diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py index cdcabd8ffe..9d328f8d54 100644 --- a/tests/template_tests/templatetags/custom.py +++ b/tests/template_tests/templatetags/custom.py @@ -107,61 +107,61 @@ register.simple_tag(lambda x: x - 1, name='minusone') @register.inclusion_tag('inclusion.html') def inclusion_no_params(): """Expected inclusion_no_params __doc__""" - return {"result" : "inclusion_no_params - Expected result"} + return {"result": "inclusion_no_params - Expected result"} inclusion_no_params.anything = "Expected inclusion_no_params __dict__" @register.inclusion_tag(get_template('inclusion.html')) def inclusion_no_params_from_template(): """Expected inclusion_no_params_from_template __doc__""" - return {"result" : "inclusion_no_params_from_template - Expected result"} + return {"result": "inclusion_no_params_from_template - Expected result"} inclusion_no_params_from_template.anything = "Expected inclusion_no_params_from_template __dict__" @register.inclusion_tag('inclusion.html') def inclusion_one_param(arg): """Expected inclusion_one_param __doc__""" - return {"result" : "inclusion_one_param - Expected result: %s" % arg} + return {"result": "inclusion_one_param - Expected result: %s" % arg} inclusion_one_param.anything = "Expected inclusion_one_param __dict__" @register.inclusion_tag(get_template('inclusion.html')) def inclusion_one_param_from_template(arg): """Expected inclusion_one_param_from_template __doc__""" - return {"result" : "inclusion_one_param_from_template - Expected result: %s" % arg} + return {"result": "inclusion_one_param_from_template - Expected result: %s" % arg} inclusion_one_param_from_template.anything = "Expected inclusion_one_param_from_template __dict__" @register.inclusion_tag('inclusion.html', takes_context=False) def inclusion_explicit_no_context(arg): """Expected inclusion_explicit_no_context __doc__""" - return {"result" : "inclusion_explicit_no_context - Expected result: %s" % arg} + return {"result": "inclusion_explicit_no_context - Expected result: %s" % arg} inclusion_explicit_no_context.anything = "Expected inclusion_explicit_no_context __dict__" @register.inclusion_tag(get_template('inclusion.html'), takes_context=False) def inclusion_explicit_no_context_from_template(arg): """Expected inclusion_explicit_no_context_from_template __doc__""" - return {"result" : "inclusion_explicit_no_context_from_template - Expected result: %s" % arg} + return {"result": "inclusion_explicit_no_context_from_template - Expected result: %s" % arg} inclusion_explicit_no_context_from_template.anything = "Expected inclusion_explicit_no_context_from_template __dict__" @register.inclusion_tag('inclusion.html', takes_context=True) def inclusion_no_params_with_context(context): """Expected inclusion_no_params_with_context __doc__""" - return {"result" : "inclusion_no_params_with_context - Expected result (context value: %s)" % context['value']} + return {"result": "inclusion_no_params_with_context - Expected result (context value: %s)" % context['value']} inclusion_no_params_with_context.anything = "Expected inclusion_no_params_with_context __dict__" @register.inclusion_tag(get_template('inclusion.html'), takes_context=True) def inclusion_no_params_with_context_from_template(context): """Expected inclusion_no_params_with_context_from_template __doc__""" - return {"result" : "inclusion_no_params_with_context_from_template - Expected result (context value: %s)" % context['value']} + return {"result": "inclusion_no_params_with_context_from_template - Expected result (context value: %s)" % context['value']} inclusion_no_params_with_context_from_template.anything = "Expected inclusion_no_params_with_context_from_template __dict__" @register.inclusion_tag('inclusion.html', takes_context=True) def inclusion_params_and_context(context, arg): """Expected inclusion_params_and_context __doc__""" - return {"result" : "inclusion_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)} + return {"result": "inclusion_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)} inclusion_params_and_context.anything = "Expected inclusion_params_and_context __dict__" @register.inclusion_tag(get_template('inclusion.html'), takes_context=True) def inclusion_params_and_context_from_template(context, arg): """Expected inclusion_params_and_context_from_template __doc__""" - return {"result" : "inclusion_params_and_context_from_template - Expected result (context value: %s): %s" % (context['value'], arg)} + return {"result": "inclusion_params_and_context_from_template - Expected result (context value: %s): %s" % (context['value'], arg)} inclusion_params_and_context_from_template.anything = "Expected inclusion_params_and_context_from_template __dict__" @register.inclusion_tag('inclusion.html') diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 2b845a0456..c617bc07d4 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -668,7 +668,7 @@ class TemplateTests(TransRealMixin, TestCase): 'basic-syntax02': ("{{ headline }}", {'headline': 'Success'}, "Success"), # More than one replacement variable is allowed in a template - 'basic-syntax03': ("{{ first }} --- {{ second }}", {"first" : 1, "second" : 2}, "1 --- 2"), + 'basic-syntax03': ("{{ first }} --- {{ second }}", {"first": 1, "second": 2}, "1 --- 2"), # Fail silently when a variable is not found in the current context 'basic-syntax04': ("as{{ missing }}df", {}, ("asdf", "asINVALIDdf")), @@ -899,8 +899,8 @@ class TemplateTests(TransRealMixin, TestCase): 'cycle17': ("{% cycle 'a' 'b' 'c' as abc silent %}{% cycle abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}", {}, ""), 'cycle18': ("{% cycle 'a' 'b' 'c' as foo invalid_flag %}", {}, template.TemplateSyntaxError), 'cycle19': ("{% cycle 'a' 'b' as silent %}{% cycle silent %}", {}, "ab"), - 'cycle20': ("{% cycle one two as foo %} & {% cycle foo %}", {'one' : 'A & B', 'two' : 'C & D'}, "A & B & C & D"), - 'cycle21': ("{% filter force_escape %}{% cycle one two as foo %} & {% cycle foo %}{% endfilter %}", {'one' : 'A & B', 'two' : 'C & D'}, "A & B & C & D"), + 'cycle20': ("{% cycle one two as foo %} & {% cycle foo %}", {'one': 'A & B', 'two': 'C & D'}, "A & B & C & D"), + 'cycle21': ("{% filter force_escape %}{% cycle one two as foo %} & {% cycle foo %}{% endfilter %}", {'one': 'A & B', 'two': 'C & D'}, "A & B & C & D"), 'cycle22': ("{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ x }}{% endfor %}", {'values': [1, 2, 3, 4]}, "1234"), 'cycle23': ("{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ abc }}{{ x }}{% endfor %}", {'values': [1, 2, 3, 4]}, "a1b2c3a4"), 'included-cycle': ('{{ abc }}', {'abc': 'xxx'}, 'xxx'), @@ -1398,9 +1398,9 @@ class TemplateTests(TransRealMixin, TestCase): 'spaceless01': ("{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}", {}, "<b><i> text </i></b>"), 'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b><i> text </i></b>"), 'spaceless03': ("{% spaceless %}<b><i>text</i></b>{% endspaceless %}", {}, "<b><i>text</i></b>"), - 'spaceless04': ("{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}", {'text' : 'This & that'}, "<b><i>This & that</i></b>"), - 'spaceless05': ("{% autoescape off %}{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}{% endautoescape %}", {'text' : 'This & that'}, "<b><i>This & that</i></b>"), - 'spaceless06': ("{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}", {'text' : 'This & that'}, "<b><i>This & that</i></b>"), + 'spaceless04': ("{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}", {'text': 'This & that'}, "<b><i>This & that</i></b>"), + 'spaceless05': ("{% autoescape off %}{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}{% endautoescape %}", {'text': 'This & that'}, "<b><i>This & that</i></b>"), + 'spaceless06': ("{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}", {'text': 'This & that'}, "<b><i>This & that</i></b>"), # simple translation of a string delimited by ' 'i18n01': ("{% load i18n %}{% trans 'xxxyyyxxx' %}", {}, "xxxyyyxxx"), diff --git a/tests/test_client/views.py b/tests/test_client/views.py index ce76865ade..1861e3a591 100644 --- a/tests/test_client/views.py +++ b/tests/test_client/views.py @@ -191,7 +191,7 @@ def _permission_protected_view(request): "A simple view that is permission protected." t = Template('This is a permission protected test. ' 'Username is {{ user.username }}. ' - 'Permissions are {{ user.get_all_permissions }}.' , + 'Permissions are {{ user.get_all_permissions }}.', name='Permissions Template') c = Context({'user': request.user}) return HttpResponse(t.render(c)) @@ -211,7 +211,7 @@ class _ViewManager(object): def permission_protected_view(self, request): t = Template('This is a permission protected test using a method. ' 'Username is {{ user.username }}. ' - 'Permissions are {{ user.get_all_permissions }}.' , + 'Permissions are {{ user.get_all_permissions }}.', name='Permissions Template') c = Context({'user': request.user}) return HttpResponse(t.render(c)) diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index af2eef6747..666fde2fa6 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -322,7 +322,7 @@ class HTMLEqualTests(TestCase): self.assertEqual(dom.children[0], "<p>foo</p> '</scr'+'ipt>' <span>bar</span>") def test_self_closing_tags(self): - self_closing_tags = ('br' , 'hr', 'input', 'img', 'meta', 'spacer', + self_closing_tags = ('br', 'hr', 'input', 'img', 'meta', 'spacer', 'link', 'frame', 'base', 'col') for tag in self_closing_tags: dom = parse_html('<p>Hello <%s> world</p>' % tag) |
