Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix all violators of E231

  • Loading branch information...
commit 9d740eb8b15de31f1c5520659df683d90342bb44 1 parent f2d8027
@alex alex authored
Showing with 628 additions and 629 deletions.
  1. +1 −1  setup.cfg
  2. +3 −3 tests/admin_scripts/management/commands/base_command.py
  3. +1 −1  tests/admin_widgets/models.py
  4. +3 −3 tests/admin_widgets/tests.py
  5. +7 −7 tests/aggregation_regress/tests.py
  6. +1 −1  tests/basic/models.py
  7. +24 −24 tests/cache/tests.py
  8. +3 −3 tests/csrf_tests/tests.py
  9. +1 −1  tests/custom_columns/models.py
  10. +1 −1  tests/custom_columns_regress/models.py
  11. +1 −1  tests/decorators/tests.py
  12. +15 −15 tests/defaultfilters/tests.py
  13. +1 −1  tests/delete_regress/tests.py
  14. +2 −2 tests/dispatch/tests/test_dispatcher.py
  15. +1 −1  tests/distinct_on_fields/tests.py
  16. +1 −1  tests/extra_regress/models.py
  17. +17 −17 tests/extra_regress/tests.py
  18. +1 −1  tests/file_storage/tests.py
  19. +1 −1  tests/file_uploads/tests.py
  20. +1 −1  tests/fixtures_model_package/tests.py
  21. +18 −18 tests/forms_tests/tests/test_extra.py
  22. +5 −5 tests/forms_tests/tests/test_fields.py
  23. +6 −6 tests/forms_tests/tests/test_forms.py
  24. +5 −5 tests/forms_tests/tests/test_formsets.py
  25. +75 −75 tests/forms_tests/tests/test_input_formats.py
  26. +86 −86 tests/forms_tests/tests/test_media.py
  27. +8 −9 tests/forms_tests/tests/test_widgets.py
  28. +1 −1  tests/forms_tests/tests/tests.py
  29. +4 −4 tests/generic_views/test_dates.py
  30. +3 −3 tests/generic_views/views.py
  31. +2 −2 tests/i18n/commands/extraction.py
  32. +1 −1  tests/i18n/models.py
  33. +1 −1  tests/i18n/patterns/tests.py
  34. +4 −4 tests/inspectdb/tests.py
  35. +2 −2 tests/lookup/tests.py
  36. +1 −1  tests/m2m_recursive/tests.py
  37. +2 −2 tests/m2m_signals/tests.py
  38. +17 −17 tests/m2m_through/tests.py
  39. +4 −4 tests/m2m_through_regress/tests.py
  40. +6 −6 tests/many_to_many/tests.py
  41. +6 −6 tests/many_to_one/tests.py
  42. +2 −2 tests/max_lengths/tests.py
  43. +1 −1  tests/model_forms/tests.py
  44. +6 −6 tests/model_forms_regress/tests.py
  45. +3 −3 tests/model_formsets_regress/tests.py
  46. +1 −1  tests/model_inheritance_regress/models.py
  47. +6 −6 tests/model_inheritance_regress/tests.py
  48. +1 −1  tests/modeladmin/tests.py
  49. +24 −24 tests/multiple_database/tests.py
  50. +3 −3 tests/prefetch_related/tests.py
  51. +7 −7 tests/queries/tests.py
  52. +1 −1  tests/queryset_pickle/models.py
  53. +4 −4 tests/raw_query/tests.py
  54. +3 −3 tests/select_related_regress/tests.py
  55. +2 −2 tests/serializers/tests.py
  56. +20 −20 tests/serializers_regress/tests.py
  57. +8 −8 tests/template_tests/filters.py
  58. +1 −1  tests/template_tests/test_response.py
  59. +2 −2 tests/template_tests/test_smartif.py
  60. +70 −70 tests/template_tests/tests.py
  61. +7 −7 tests/test_client/tests.py
  62. +1 −1  tests/test_client/views.py
  63. +21 −21 tests/test_client_regress/tests.py
  64. +1 −1  tests/test_client_regress/urls.py
  65. +1 −1  tests/test_client_regress/views.py
  66. +7 −7 tests/test_runner/tests.py
  67. +1 −1  tests/update_only_fields/tests.py
  68. +38 −38 tests/urlpatterns_reverse/tests.py
  69. +7 −7 tests/utils_tests/test_datastructures.py
  70. +1 −1  tests/utils_tests/test_html.py
  71. +30 −30 tests/utils_tests/test_termcolors.py
  72. +1 −1  tests/validation/test_unique.py
  73. +3 −3 tests/validation/tests.py
  74. +1 −1  tests/view_tests/tests/test_debug.py
View
2  setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8]
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py
-ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E203,E231,E261,F401,F403,W601
+ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E203,E261,F401,F403,W601
[metadata]
license-file = LICENSE
View
6 tests/admin_scripts/management/commands/base_command.py
@@ -5,9 +5,9 @@
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
- make_option('--option_a','-a', action='store', dest='option_a', default='1'),
- make_option('--option_b','-b', action='store', dest='option_b', default='2'),
- make_option('--option_c','-c', action='store', dest='option_c', default='3'),
+ make_option('--option_a', '-a', action='store', dest='option_a', default='1'),
+ make_option('--option_b', '-b', action='store', dest='option_b', default='2'),
+ make_option('--option_c', '-c', action='store', dest='option_c', default='3'),
)
help = 'Test basic commands'
requires_model_validation = False
View
2  tests/admin_widgets/models.py
@@ -12,7 +12,7 @@ class MyFileField(models.FileField):
class Member(models.Model):
name = models.CharField(max_length=100)
birthdate = models.DateTimeField(blank=True, null=True)
- gender = models.CharField(max_length=1, blank=True, choices=[('M','Male'), ('F', 'Female')])
+ gender = models.CharField(max_length=1, blank=True, choices=[('M', 'Male'), ('F', 'Female')])
email = models.EmailField(blank=True)
def __str__(self):
View
6 tests/admin_widgets/tests.py
@@ -101,7 +101,7 @@ def testRawIDForeignKey(self):
def testRadioFieldsForeignKey(self):
ff = self.assertFormfield(models.Event, 'main_band', widgets.AdminRadioSelect,
- radio_fields={'main_band':admin.VERTICAL})
+ radio_fields={'main_band': admin.VERTICAL})
self.assertEqual(ff.empty_label, None)
def testManyToMany(self):
@@ -126,7 +126,7 @@ def testFormfieldOverridesWidgetInstances(self):
"""
class BandAdmin(admin.ModelAdmin):
formfield_overrides = {
- CharField: {'widget': forms.TextInput(attrs={'size':'10'})}
+ CharField: {'widget': forms.TextInput(attrs={'size': '10'})}
}
ma = BandAdmin(models.Band, admin.site)
f1 = ma.formfield_for_dbfield(models.Band._meta.get_field('name'), request=None)
@@ -158,7 +158,7 @@ def testFieldWithChoices(self):
def testChoicesWithRadioFields(self):
self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,
- radio_fields={'gender':admin.VERTICAL})
+ radio_fields={'gender': admin.VERTICAL})
def testInheritance(self):
self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget)
View
14 tests/aggregation_regress/tests.py
@@ -196,7 +196,7 @@ def test_annotation(self):
"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',
@@ -346,7 +346,7 @@ def test_more(self):
def test_aggregate_fexpr(self):
# Aggregates can be used with F() expressions
# ... where the F() is pushed into the HAVING clause
- qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')
+ qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
self.assertQuerysetEqual(
qs, [
{'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},
@@ -355,7 +355,7 @@ def test_aggregate_fexpr(self):
lambda p: p,
)
- qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')
+ qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
self.assertQuerysetEqual(
qs, [
{'num_books': 2, 'name': 'Apress', 'num_awards': 3},
@@ -366,7 +366,7 @@ def test_aggregate_fexpr(self):
)
# ... and where the F() references an aggregate
- qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_awards__gt=2*F('num_books')).order_by('name').values('name','num_books','num_awards')
+ qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_awards__gt=2*F('num_books')).order_by('name').values('name', 'num_books', 'num_awards')
self.assertQuerysetEqual(
qs, [
{'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},
@@ -375,7 +375,7 @@ def test_aggregate_fexpr(self):
lambda p: p,
)
- qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')
+ qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name', 'num_books', 'num_awards')
self.assertQuerysetEqual(
qs, [
{'num_books': 2, 'name': 'Apress', 'num_awards': 3},
@@ -456,7 +456,7 @@ def test_more_more(self):
# Regression for #10132 - If the values() clause only mentioned extra
# (select=) columns, those columns are used for grouping
- qs = Book.objects.extra(select={'pub':'publisher_id'}).values('pub').annotate(Count('id')).order_by('pub')
+ qs = Book.objects.extra(select={'pub': 'publisher_id'}).values('pub').annotate(Count('id')).order_by('pub')
self.assertQuerysetEqual(
qs, [
{'pub': 1, 'id__count': 2},
@@ -467,7 +467,7 @@ def test_more_more(self):
lambda b: b
)
- qs = Book.objects.extra(select={'pub':'publisher_id', 'foo':'pages'}).values('pub').annotate(Count('id')).order_by('pub')
+ qs = Book.objects.extra(select={'pub': 'publisher_id', 'foo': 'pages'}).values('pub').annotate(Count('id')).order_by('pub')
self.assertQuerysetEqual(
qs, [
{'pub': 1, 'id__count': 2},
View
2  tests/basic/models.py
@@ -14,7 +14,7 @@ class Article(models.Model):
pub_date = models.DateTimeField()
class Meta:
- ordering = ('pub_date','headline')
+ ordering = ('pub_date', 'headline')
def __str__(self):
return self.headline
View
48 tests/cache/tests.py
@@ -682,55 +682,55 @@ def test_cache_versioning_incr_decr(self):
def test_cache_versioning_get_set_many(self):
# set, using default version = 1
self.cache.set_many({'ford1': 37, 'arthur1': 42})
- self.assertEqual(self.cache.get_many(['ford1','arthur1']),
+ self.assertEqual(self.cache.get_many(['ford1', 'arthur1']),
{'ford1': 37, 'arthur1': 42})
- self.assertEqual(self.cache.get_many(['ford1','arthur1'], version=1),
+ self.assertEqual(self.cache.get_many(['ford1', 'arthur1'], version=1),
{'ford1': 37, 'arthur1': 42})
- self.assertEqual(self.cache.get_many(['ford1','arthur1'], version=2), {})
+ self.assertEqual(self.cache.get_many(['ford1', 'arthur1'], version=2), {})
- self.assertEqual(self.v2_cache.get_many(['ford1','arthur1']), {})
- self.assertEqual(self.v2_cache.get_many(['ford1','arthur1'], version=1),
+ self.assertEqual(self.v2_cache.get_many(['ford1', 'arthur1']), {})
+ self.assertEqual(self.v2_cache.get_many(['ford1', 'arthur1'], version=1),
{'ford1': 37, 'arthur1': 42})
- self.assertEqual(self.v2_cache.get_many(['ford1','arthur1'], version=2), {})
+ self.assertEqual(self.v2_cache.get_many(['ford1', 'arthur1'], version=2), {})
# set, default version = 1, but manually override version = 2
self.cache.set_many({'ford2': 37, 'arthur2': 42}, version=2)
- self.assertEqual(self.cache.get_many(['ford2','arthur2']), {})
- self.assertEqual(self.cache.get_many(['ford2','arthur2'], version=1), {})
- self.assertEqual(self.cache.get_many(['ford2','arthur2'], version=2),
+ self.assertEqual(self.cache.get_many(['ford2', 'arthur2']), {})
+ self.assertEqual(self.cache.get_many(['ford2', 'arthur2'], version=1), {})
+ self.assertEqual(self.cache.get_many(['ford2', 'arthur2'], version=2),
{'ford2': 37, 'arthur2': 42})
- self.assertEqual(self.v2_cache.get_many(['ford2','arthur2']),
+ self.assertEqual(self.v2_cache.get_many(['ford2', 'arthur2']),
{'ford2': 37, 'arthur2': 42})
- self.assertEqual(self.v2_cache.get_many(['ford2','arthur2'], version=1), {})
- self.assertEqual(self.v2_cache.get_many(['ford2','arthur2'], version=2),
+ self.assertEqual(self.v2_cache.get_many(['ford2', 'arthur2'], version=1), {})
+ self.assertEqual(self.v2_cache.get_many(['ford2', 'arthur2'], version=2),
{'ford2': 37, 'arthur2': 42})
# v2 set, using default version = 2
self.v2_cache.set_many({'ford3': 37, 'arthur3': 42})
- self.assertEqual(self.cache.get_many(['ford3','arthur3']), {})
- self.assertEqual(self.cache.get_many(['ford3','arthur3'], version=1), {})
- self.assertEqual(self.cache.get_many(['ford3','arthur3'], version=2),
+ self.assertEqual(self.cache.get_many(['ford3', 'arthur3']), {})
+ self.assertEqual(self.cache.get_many(['ford3', 'arthur3'], version=1), {})
+ self.assertEqual(self.cache.get_many(['ford3', 'arthur3'], version=2),
{'ford3': 37, 'arthur3': 42})
- self.assertEqual(self.v2_cache.get_many(['ford3','arthur3']),
+ self.assertEqual(self.v2_cache.get_many(['ford3', 'arthur3']),
{'ford3': 37, 'arthur3': 42})
- self.assertEqual(self.v2_cache.get_many(['ford3','arthur3'], version=1), {})
- self.assertEqual(self.v2_cache.get_many(['ford3','arthur3'], version=2),
+ self.assertEqual(self.v2_cache.get_many(['ford3', 'arthur3'], version=1), {})
+ self.assertEqual(self.v2_cache.get_many(['ford3', 'arthur3'], version=2),
{'ford3': 37, 'arthur3': 42})
# v2 set, default version = 2, but manually override version = 1
self.v2_cache.set_many({'ford4': 37, 'arthur4': 42}, version=1)
- self.assertEqual(self.cache.get_many(['ford4','arthur4']),
+ self.assertEqual(self.cache.get_many(['ford4', 'arthur4']),
{'ford4': 37, 'arthur4': 42})
- self.assertEqual(self.cache.get_many(['ford4','arthur4'], version=1),
+ self.assertEqual(self.cache.get_many(['ford4', 'arthur4'], version=1),
{'ford4': 37, 'arthur4': 42})
- self.assertEqual(self.cache.get_many(['ford4','arthur4'], version=2), {})
+ self.assertEqual(self.cache.get_many(['ford4', 'arthur4'], version=2), {})
- self.assertEqual(self.v2_cache.get_many(['ford4','arthur4']), {})
- self.assertEqual(self.v2_cache.get_many(['ford4','arthur4'], version=1),
+ self.assertEqual(self.v2_cache.get_many(['ford4', 'arthur4']), {})
+ self.assertEqual(self.v2_cache.get_many(['ford4', 'arthur4'], version=1),
{'ford4': 37, 'arthur4': 42})
- self.assertEqual(self.v2_cache.get_many(['ford4','arthur4'], version=2), {})
+ self.assertEqual(self.v2_cache.get_many(['ford4', 'arthur4'], version=2), {})
def test_incr_version(self):
self.cache.set('answer', 42, version=2)
View
6 tests/csrf_tests/tests.py
@@ -115,7 +115,7 @@ def test_process_response_get_token_used(self):
self.assertEqual(csrf_cookie['secure'], True)
self.assertEqual(csrf_cookie['httponly'], True)
self.assertEqual(csrf_cookie['path'], '/test/')
- self.assertTrue('Cookie' in resp2.get('Vary',''))
+ self.assertTrue('Cookie' in resp2.get('Vary', ''))
def test_process_response_get_token_not_used(self):
"""
@@ -336,7 +336,7 @@ def view(request):
req = self._get_GET_no_csrf_cookie_request()
resp = view(req)
self.assertTrue(resp.cookies.get(settings.CSRF_COOKIE_NAME, False))
- self.assertTrue('Cookie' in resp.get('Vary',''))
+ self.assertTrue('Cookie' in resp.get('Vary', ''))
def test_ensures_csrf_cookie_with_middleware(self):
"""
@@ -353,7 +353,7 @@ def view(request):
resp = view(req)
resp2 = CsrfViewMiddleware().process_response(req, resp)
self.assertTrue(resp2.cookies.get(settings.CSRF_COOKIE_NAME, False))
- self.assertTrue('Cookie' in resp2.get('Vary',''))
+ self.assertTrue('Cookie' in resp2.get('Vary', ''))
def test_ensures_csrf_cookie_no_logging(self):
"""
View
2  tests/custom_columns/models.py
@@ -31,7 +31,7 @@ def __str__(self):
class Meta:
db_table = 'my_author_table'
- ordering = ('last_name','first_name')
+ ordering = ('last_name', 'first_name')
@python_2_unicode_compatible
class Article(models.Model):
View
2  tests/custom_columns_regress/models.py
@@ -35,4 +35,4 @@ def __str__(self):
class Meta:
db_table = 'my author table'
- ordering = ('last_name','first_name')
+ ordering = ('last_name', 'first_name')
View
2  tests/decorators/tests.py
@@ -50,7 +50,7 @@ def _inner(*args, **kwargs):
# django.contrib.auth.decorators
# Apply user_passes_test twice to check #9474
- user_passes_test(lambda u:True),
+ user_passes_test(lambda u: True),
login_required,
permission_required('change_world'),
View
30 tests/defaultfilters/tests.py
@@ -369,7 +369,7 @@ def test_wordcount(self):
'should be\nindented')
self.assertEqual(wordwrap('this is a short paragraph of text.\n '
- 'But this line should be indented',15), 'this is a short\n'
+ 'But this line should be indented', 15), 'this is a short\n'
'paragraph of\ntext.\n But this line\nshould be\nindented')
def test_rjust(self):
@@ -460,16 +460,16 @@ def test_dictsortreversed(self):
self.assertEqual(dictsortreversed(1, 'age'), '')
def test_first(self):
- self.assertEqual(first([0,1,2]), 0)
+ self.assertEqual(first([0, 1, 2]), 0)
self.assertEqual(first(''), '')
self.assertEqual(first('test'), 't')
def test_join(self):
- self.assertEqual(join([0,1,2], 'glue'), '0glue1glue2')
+ self.assertEqual(join([0, 1, 2], 'glue'), '0glue1glue2')
def test_length(self):
self.assertEqual(length('1234'), 4)
- self.assertEqual(length([1,2,3,4]), 4)
+ self.assertEqual(length([1, 2, 3, 4]), 4)
self.assertEqual(length_is([], 0), True)
self.assertEqual(length_is([], 1), False)
self.assertEqual(length_is('a', 1), True)
@@ -517,7 +517,7 @@ def __str__(self):
a = ULItem('a')
b = ULItem('b')
- self.assertEqual(unordered_list([a,b]),
+ self.assertEqual(unordered_list([a, b]),
'\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>')
# Old format for unordered lists should still work
@@ -623,7 +623,7 @@ def test_filesizeformat(self):
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024), '1.0\xa0PB')
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
'2000.0\xa0PB')
- self.assertEqual(filesizeformat(complex(1,-1)), '0\xa0bytes')
+ self.assertEqual(filesizeformat(complex(1, -1)), '0\xa0bytes')
self.assertEqual(filesizeformat(""), '0\xa0bytes')
self.assertEqual(filesizeformat("\N{GREEK SMALL LETTER ALPHA}"),
'0\xa0bytes')
@@ -634,14 +634,14 @@ def test_pluralize(self):
self.assertEqual(pluralize(2), 's')
self.assertEqual(pluralize([1]), '')
self.assertEqual(pluralize([]), 's')
- self.assertEqual(pluralize([1,2,3]), 's')
- self.assertEqual(pluralize(1,'es'), '')
- self.assertEqual(pluralize(0,'es'), 'es')
- self.assertEqual(pluralize(2,'es'), 'es')
- self.assertEqual(pluralize(1,'y,ies'), 'y')
- self.assertEqual(pluralize(0,'y,ies'), 'ies')
- self.assertEqual(pluralize(2,'y,ies'), 'ies')
- self.assertEqual(pluralize(0,'y,ies,error'), '')
+ self.assertEqual(pluralize([1, 2, 3]), 's')
+ self.assertEqual(pluralize(1, 'es'), '')
+ self.assertEqual(pluralize(0, 'es'), 'es')
+ self.assertEqual(pluralize(2, 'es'), 'es')
+ self.assertEqual(pluralize(1, 'y,ies'), 'y')
+ self.assertEqual(pluralize(0, 'y,ies'), 'ies')
+ self.assertEqual(pluralize(2, 'y,ies'), 'ies')
+ self.assertEqual(pluralize(0, 'y,ies,error'), '')
def test_phone2numeric(self):
self.assertEqual(phone2numeric_filter('0800 flowers'), '0800 3569377')
@@ -691,7 +691,7 @@ def test_localized_filesizeformat(self):
'1,0\xa0PB')
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
'2000,0\xa0PB')
- self.assertEqual(filesizeformat(complex(1,-1)), '0\xa0Bytes')
+ self.assertEqual(filesizeformat(complex(1, -1)), '0\xa0Bytes')
self.assertEqual(filesizeformat(""), '0\xa0Bytes')
self.assertEqual(filesizeformat("\N{GREEK SMALL LETTER ALPHA}"),
'0\xa0Bytes')
View
2  tests/delete_regress/tests.py
@@ -303,7 +303,7 @@ def test_ticket_19102_extra(self):
Login.objects.order_by('description').filter(
orgunit__name__isnull=False
).extra(
- select={'extraf':'1'}
+ select={'extraf': '1'}
).filter(
pk=self.l1.pk
).delete()
View
4 tests/dispatch/tests/test_dispatcher.py
@@ -51,7 +51,7 @@ def _testIsClean(self, signal):
def testExact(self):
a_signal.connect(receiver_1_arg, sender=self)
- expected = [(receiver_1_arg,"test")]
+ expected = [(receiver_1_arg, "test")]
result = a_signal.send(sender=self, val="test")
self.assertEqual(result, expected)
a_signal.disconnect(receiver_1_arg, sender=self)
@@ -59,7 +59,7 @@ def testExact(self):
def testIgnoredSender(self):
a_signal.connect(receiver_1_arg)
- expected = [(receiver_1_arg,"test")]
+ expected = [(receiver_1_arg, "test")]
result = a_signal.send(sender=self, val="test")
self.assertEqual(result, expected)
a_signal.disconnect(receiver_1_arg)
View
2  tests/distinct_on_fields/tests.py
@@ -63,7 +63,7 @@ def test_basic_distinct_on(self):
['<Celebrity: c1>', '<Celebrity: c2>'],
),
(
- StaffTag.objects.distinct('staff','tag'),
+ StaffTag.objects.distinct('staff', 'tag'),
['<StaffTag: t1 -> p1>'],
),
(
View
2  tests/extra_regress/models.py
@@ -41,4 +41,4 @@ class TestObject(models.Model):
third = models.CharField(max_length=20)
def __str__(self):
- return 'TestObject: %s,%s,%s' % (self.first,self.second,self.third)
+ return 'TestObject: %s,%s,%s' % (self.first, self.second, self.third)
View
34 tests/extra_regress/tests.py
@@ -180,100 +180,100 @@ def test_values_with_extra(self):
obj.save()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values()),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values()),
[{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
)
# Extra clauses after an empty values clause are still included
self.assertEqual(
- list(TestObject.objects.values().extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
+ list(TestObject.objects.values().extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
[{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
)
# Extra columns are ignored if not mentioned in the values() clause
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('first', 'second')),
[{'second': 'second', 'first': 'first'}]
)
# Extra columns after a non-empty values() clause are ignored
self.assertEqual(
- list(TestObject.objects.values('first', 'second').extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
+ list(TestObject.objects.values('first', 'second').extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
[{'second': 'second', 'first': 'first'}]
)
# Extra columns can be partially returned
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second', 'foo')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('first', 'second', 'foo')),
[{'second': 'second', 'foo': 'first', 'first': 'first'}]
)
# Also works if only extra columns are included
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('foo', 'whiz')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values('foo', 'whiz')),
[{'foo': 'first', 'whiz': 'third'}]
)
# Values list works the same way
# All columns are returned for an empty values_list()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list()),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list()),
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
)
# Extra columns after an empty values_list() are still included
self.assertEqual(
- list(TestObject.objects.values_list().extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
+ list(TestObject.objects.values_list().extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
)
# Extra columns ignored completely if not mentioned in values_list()
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'second')),
[('first', 'second')]
)
# Extra columns after a non-empty values_list() clause are ignored completely
self.assertEqual(
- list(TestObject.objects.values_list('first', 'second').extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
+ list(TestObject.objects.values_list('first', 'second').extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third'))))),
[('first', 'second')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('second', flat=True)),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('second', flat=True)),
['second']
)
# Only the extra columns specified in the values_list() are returned
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second', 'whiz')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'second', 'whiz')),
[('first', 'second', 'third')]
)
# ...also works if only extra columns are included
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('foo','whiz')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('foo', 'whiz')),
[('first', 'third')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', flat=True)),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', flat=True)),
['third']
)
# ... and values are returned in the order they are specified
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz','foo')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', 'foo')),
[('third', 'first')]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first','id')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('first', 'id')),
[('first', obj.pk)]
)
self.assertEqual(
- list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', 'first', 'bar', 'id')),
+ list(TestObject.objects.extra(select=OrderedDict((('foo', 'first'), ('bar', 'second'), ('whiz', 'third')))).values_list('whiz', 'first', 'bar', 'id')),
[('third', 'first', 'second', obj.pk)]
)
View
2  tests/file_storage/tests.py
@@ -403,7 +403,7 @@ def test_unicode_file_names(self):
out the encoding situation between doctest and this file, but the actual
repr doesn't matter; it just shouldn't return a unicode object.
"""
- uf = UploadedFile(name='¿Cómo?',content_type='text')
+ uf = UploadedFile(name='¿Cómo?', content_type='text')
self.assertEqual(type(uf.__repr__()), str)
# Tests for a race condition on file saving (#4948).
View
2  tests/file_uploads/tests.py
@@ -80,7 +80,7 @@ def _test_base64_upload(self, content):
'Content-Disposition: form-data; name="file"; filename="test.txt"',
'Content-Type: application/octet-stream',
'Content-Transfer-Encoding: base64',
- '',]))
+ '']))
payload.write(b"\r\n" + base64.b64encode(force_bytes(content)) + b"\r\n")
payload.write('--' + client.BOUNDARY + '--\r\n')
r = {
View
2  tests/fixtures_model_package/tests.py
@@ -17,7 +17,7 @@ def testClassFixtures(self):
"Test cases can load fixture objects into models defined in packages"
self.assertEqual(Article.objects.count(), 3)
self.assertQuerysetEqual(
- Article.objects.all(),[
+ Article.objects.all(), [
"Django conquers world!",
"Copyright is fine the way it is",
"Poker has no place on ESPN",
View
36 tests/forms_tests/tests/test_extra.py
@@ -38,7 +38,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
# The forms library comes with some extra, higher-level Field and Widget
def test_selectdate(self):
- w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'))
+ w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'))
# Rendering the default state.
self.assertHTMLEqual(w.render('mydate', ''), """<select name="mydate_month" id="id_mydate_month">
@@ -293,7 +293,7 @@ def test_selectdate(self):
</select>""")
# Using a SelectDateWidget in a form.
- w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'), required=False)
+ w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'), required=False)
self.assertHTMLEqual(w.render('mydate', ''), """<select name="mydate_month" id="id_mydate_month">
<option value="0">---</option>
<option value="1">January</option>
@@ -419,7 +419,7 @@ def test_selectdate(self):
<option value="2016">2016</option>
</select>""")
- a = GetDate({'mydate_month':'4', 'mydate_day':'1', 'mydate_year':'2008'})
+ a = GetDate({'mydate_month': '4', 'mydate_day': '1', 'mydate_year': '2008'})
self.assertTrue(a.is_valid())
self.assertEqual(a.cleaned_data['mydate'], datetime.date(2008, 4, 1))
@@ -429,17 +429,17 @@ def test_selectdate(self):
self.assertHTMLEqual(a['mydate'].as_hidden(), '<input type="hidden" name="mydate" value="2008-4-1" id="id_mydate" />')
- b = GetDate({'mydate':'2008-4-1'})
+ b = GetDate({'mydate': '2008-4-1'})
self.assertTrue(b.is_valid())
self.assertEqual(b.cleaned_data['mydate'], datetime.date(2008, 4, 1))
# Invalid dates shouldn't be allowed
- c = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'})
+ c = GetDate({'mydate_month': '2', 'mydate_day': '31', 'mydate_year': '2010'})
self.assertFalse(c.is_valid())
self.assertEqual(c.errors, {'mydate': ['Enter a valid date.']})
# label tag is correctly associated with month dropdown
- d = GetDate({'mydate_month':'1', 'mydate_day':'1', 'mydate_year':'2010'})
+ d = GetDate({'mydate_month': '1', 'mydate_day': '1', 'mydate_year': '2010'})
self.assertTrue('<label for="id_mydate_month">' in d.as_p())
def test_multiwidget(self):
@@ -488,31 +488,31 @@ def __init__(self, required=True, widget=None, label=None, initial=None):
def compress(self, data_list):
if data_list:
- return '%s,%s,%s' % (data_list[0],''.join(data_list[1]),data_list[2])
+ return '%s,%s,%s' % (data_list[0], ''.join(data_list[1]), data_list[2])
return None
f = ComplexField(widget=w)
- self.assertEqual(f.clean(['some text', ['J','P'], ['2007-04-25','6:24:00']]), 'some text,JP,2007-04-25 06:24:00')
- self.assertFormErrors(['Select a valid choice. X is not one of the available choices.'], f.clean, ['some text',['X'], ['2007-04-25','6:24:00']])
+ self.assertEqual(f.clean(['some text', ['J', 'P'], ['2007-04-25', '6:24:00']]), 'some text,JP,2007-04-25 06:24:00')
+ self.assertFormErrors(['Select a valid choice. X is not one of the available choices.'], f.clean, ['some text', ['X'], ['2007-04-25', '6:24:00']])
# If insufficient data is provided, None is substituted
- self.assertFormErrors(['This field is required.'], f.clean, ['some text',['JP']])
+ self.assertFormErrors(['This field is required.'], f.clean, ['some text', ['JP']])
# test with no initial data
- self.assertTrue(f._has_changed(None, ['some text', ['J','P'], ['2007-04-25','6:24:00']]))
+ self.assertTrue(f._has_changed(None, ['some text', ['J', 'P'], ['2007-04-25', '6:24:00']]))
# test when the data is the same as initial
self.assertFalse(f._has_changed('some text,JP,2007-04-25 06:24:00',
- ['some text', ['J','P'], ['2007-04-25','6:24:00']]))
+ ['some text', ['J', 'P'], ['2007-04-25', '6:24:00']]))
# test when the first widget's data has changed
self.assertTrue(f._has_changed('some text,JP,2007-04-25 06:24:00',
- ['other text', ['J','P'], ['2007-04-25','6:24:00']]))
+ ['other text', ['J', 'P'], ['2007-04-25', '6:24:00']]))
# test when the last widget's data has changed. this ensures that it is not
# short circuiting while testing the widgets.
self.assertTrue(f._has_changed('some text,JP,2007-04-25 06:24:00',
- ['some text', ['J','P'], ['2009-04-25','11:44:00']]))
+ ['some text', ['J', 'P'], ['2009-04-25', '11:44:00']]))
class ComplexFieldForm(Form):
field1 = ComplexField(widget=w)
@@ -527,7 +527,7 @@ class ComplexFieldForm(Form):
</select>
<input type="text" name="field1_2_0" id="id_field1_2_0" /><input type="text" name="field1_2_1" id="id_field1_2_1" /></td></tr>""")
- f = ComplexFieldForm({'field1_0':'some text','field1_1':['J','P'], 'field1_2_0':'2007-04-25', 'field1_2_1':'06:24:00'})
+ f = ComplexFieldForm({'field1_0': 'some text', 'field1_1': ['J', 'P'], 'field1_2_0': '2007-04-25', 'field1_2_1': '06:24:00'})
self.assertHTMLEqual(f.as_table(), """<tr><th><label for="id_field1_0">Field1:</label></th><td><input type="text" name="field1_0" value="some text" id="id_field1_0" />
<select multiple="multiple" name="field1_1" id="id_field1_1">
<option value="J" selected="selected">John</option>
@@ -785,7 +785,7 @@ def tearDown(self):
super(FormsExtraL10NTestCase, self).tearDown()
def test_l10n(self):
- w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'), required=False)
+ w = SelectDateWidget(years=('2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016'), required=False)
self.assertEqual(w.value_from_datadict({'date_year': '2010', 'date_month': '8', 'date_day': '13'}, {}, 'date'), '13-08-2010')
self.assertHTMLEqual(w.render('date', '13-08-2010'), """<select name="date_day" id="id_date_day">
@@ -911,12 +911,12 @@ def test_l10n_date_changed(self):
def test_l10n_invalid_date_in(self):
# Invalid dates shouldn't be allowed
- a = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'})
+ a = GetDate({'mydate_month': '2', 'mydate_day': '31', 'mydate_year': '2010'})
self.assertFalse(a.is_valid())
# 'Geef een geldige datum op.' = 'Enter a valid date.'
self.assertEqual(a.errors, {'mydate': ['Geef een geldige datum op.']})
def test_form_label_association(self):
# label tag is correctly associated with first rendered dropdown
- a = GetDate({'mydate_month':'1', 'mydate_day':'1', 'mydate_year':'2010'})
+ a = GetDate({'mydate_month': '1', 'mydate_day': '1', 'mydate_year': '2010'})
self.assertTrue('<label for="id_mydate_day">' in a.as_p())
View
10 tests/forms_tests/tests/test_fields.py
@@ -905,7 +905,7 @@ def test_choicefield_3(self):
self.assertRaisesMessage(ValidationError, "'Select a valid choice. John is not one of the available choices.'", f.clean, 'John')
def test_choicefield_4(self):
- f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')])
+ f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3', 'A'), ('4', 'B'))), ('5', 'Other')])
self.assertEqual('1', f.clean(1))
self.assertEqual('1', f.clean('1'))
self.assertEqual('3', f.clean(3))
@@ -1043,7 +1043,7 @@ def test_multiplechoicefield_2(self):
self.assertRaisesMessage(ValidationError, "'Select a valid choice. 3 is not one of the available choices.'", f.clean, ['3'])
def test_multiplechoicefield_3(self):
- f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')])
+ f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3', 'A'), ('4', 'B'))), ('5', 'Other')])
self.assertEqual(['1'], f.clean([1]))
self.assertEqual(['1'], f.clean(['1']))
self.assertEqual(['1', '5'], f.clean([1, 5]))
@@ -1051,7 +1051,7 @@ def test_multiplechoicefield_3(self):
self.assertEqual(['1', '5'], f.clean(['1', 5]))
self.assertEqual(['1', '5'], f.clean(['1', '5']))
self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['6'])
- self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['1','6'])
+ self.assertRaisesMessage(ValidationError, "'Select a valid choice. 6 is not one of the available choices.'", f.clean, ['1', '6'])
def test_multiplechoicefield_changed(self):
f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two'), ('3', 'Three')])
@@ -1084,8 +1084,8 @@ def test_typedmultiplechoicefield_3(self):
def test_typedmultiplechoicefield_4(self):
f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
- self.assertEqual([1, -1], f.clean(['1','-1']))
- self.assertRaisesMessage(ValidationError, "'Select a valid choice. 2 is not one of the available choices.'", f.clean, ['1','2'])
+ self.assertEqual([1, -1], f.clean(['1', '-1']))
+ self.assertRaisesMessage(ValidationError, "'Select a valid choice. 2 is not one of the available choices.'", f.clean, ['1', '2'])
def test_typedmultiplechoicefield_5(self):
# Even more weirdness: if you have a valid choice but your coercion function
View
12 tests/forms_tests/tests/test_forms.py
@@ -1124,7 +1124,7 @@ def test_callable_initial_data(self):
class UserRegistration(Form):
username = CharField(max_length=10)
password = CharField(widget=PasswordInput)
- options = MultipleChoiceField(choices=[('f','foo'),('b','bar'),('w','whiz')])
+ options = MultipleChoiceField(choices=[('f', 'foo'), ('b', 'bar'), ('w', 'whiz')])
# We need to define functions that get called later.)
def initial_django():
@@ -1134,10 +1134,10 @@ def initial_stephane():
return 'stephane'
def initial_options():
- return ['f','b']
+ return ['f', 'b']
def initial_other_options():
- return ['b','w']
+ return ['b', 'w']
# Here, we're not submitting any data, so the initial value will be displayed.)
p = UserRegistration(initial={'username': initial_django, 'options': initial_options}, auto_id=False)
@@ -1166,7 +1166,7 @@ def initial_other_options():
<option value="b">bar</option>
<option value="w">whiz</option>
</select></li>""")
- p = UserRegistration({'username': 'foo', 'options':['f','b']}, initial={'username': initial_django}, auto_id=False)
+ p = UserRegistration({'username': 'foo', 'options': ['f', 'b']}, initial={'username': initial_django}, auto_id=False)
self.assertHTMLEqual(p.as_ul(), """<li>Username: <input type="text" name="username" value="foo" maxlength="10" /></li>
<li><ul class="errorlist"><li>This field is required.</li></ul>Password: <input type="password" name="password" /></li>
<li>Options: <select multiple="multiple" name="options">
@@ -1187,7 +1187,7 @@ def initial_other_options():
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)
+ 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>
@@ -1813,7 +1813,7 @@ def test_multivalue_deep_copy(self):
class ChoicesField(MultiValueField):
def __init__(self, fields=(), *args, **kwargs):
fields = (ChoiceField(label='Rank',
- choices=((1,1),(2,2))),
+ choices=((1, 1), (2, 2))),
CharField(label='Name', max_length=10))
super(ChoicesField, self).__init__(fields=fields, *args, **kwargs)
View
10 tests/forms_tests/tests/test_formsets.py
@@ -1106,19 +1106,19 @@ class Choice(Form):
class FormsetAsFooTests(TestCase):
def test_as_table(self):
formset = ChoiceFormSet(data, auto_id=False, prefix='choices')
- self.assertHTMLEqual(formset.as_table(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
+ self.assertHTMLEqual(formset.as_table(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
<tr><th>Choice:</th><td><input type="text" name="choices-0-choice" value="Calexico" /></td></tr>
<tr><th>Votes:</th><td><input type="number" name="choices-0-votes" value="100" /></td></tr>""")
def test_as_p(self):
formset = ChoiceFormSet(data, auto_id=False, prefix='choices')
- self.assertHTMLEqual(formset.as_p(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
+ self.assertHTMLEqual(formset.as_p(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
<p>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></p>
<p>Votes: <input type="number" name="choices-0-votes" value="100" /></p>""")
def test_as_ul(self):
formset = ChoiceFormSet(data, auto_id=False, prefix='choices')
- self.assertHTMLEqual(formset.as_ul(),"""<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
+ self.assertHTMLEqual(formset.as_ul(), """<input type="hidden" name="choices-TOTAL_FORMS" value="1" /><input type="hidden" name="choices-INITIAL_FORMS" value="0" /><input type="hidden" name="choices-MIN_NUM_FORMS" value="0" /><input type="hidden" name="choices-MAX_NUM_FORMS" value="0" />
<li>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></li>
<li>Votes: <input type="number" name="choices-0-votes" value="100" /></li>""")
@@ -1188,8 +1188,8 @@ class TestEmptyFormSet(TestCase):
def test_empty_formset_is_valid(self):
"""Test that an empty formset still calls clean()"""
EmptyFsetWontValidateFormset = formset_factory(FavoriteDrinkForm, extra=0, formset=EmptyFsetWontValidate)
- formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'0'},prefix="form")
- formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah'},prefix="form")
+ formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS': '0', 'form-TOTAL_FORMS': '0'}, prefix="form")
+ formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS': '0', 'form-TOTAL_FORMS': '1', 'form-0-name': 'bah'}, prefix="form")
self.assertFalse(formset.is_valid())
self.assertFalse(formset2.is_valid())
View
150 tests/forms_tests/tests/test_input_formats.py
@@ -24,7 +24,7 @@ def test_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30:05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -32,7 +32,7 @@ def test_timeField(self):
# Parse a time in a valid, but non-default format, get a parsed result
result = f.clean('13:30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -40,7 +40,7 @@ def test_timeField(self):
# ISO formats are accepted, even if not specified in formats.py
result = f.clean('13:30:05.000155')
- self.assertEqual(result, time(13,30,5,155))
+ self.assertEqual(result, time(13, 30, 5, 155))
def test_localized_timeField(self):
"Localized TimeFields act as unlocalized widgets"
@@ -50,7 +50,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30:05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -58,7 +58,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -73,7 +73,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30.05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -81,7 +81,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -96,7 +96,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30.05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -104,7 +104,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -121,7 +121,7 @@ def test_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30:05 PM')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -129,7 +129,7 @@ def test_timeField(self):
# Parse a time in a valid, but non-default format, get a parsed result
result = f.clean('1:30 PM')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -143,7 +143,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30:05 PM')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -151,7 +151,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('01:30 PM')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -166,7 +166,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30.05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -174,7 +174,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -189,7 +189,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30.05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# # Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -197,7 +197,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13.30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -213,7 +213,7 @@ def test_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30:05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -221,7 +221,7 @@ def test_timeField(self):
# Parse a time in a valid, but non-default format, get a parsed result
result = f.clean('13:30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -235,7 +235,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30:05')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -243,7 +243,7 @@ def test_localized_timeField(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('13:30')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -257,7 +257,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30:05 PM')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -265,7 +265,7 @@ def test_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30 PM')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -279,7 +279,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30:05 PM')
- self.assertEqual(result, time(13,30,5))
+ self.assertEqual(result, time(13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -287,7 +287,7 @@ def test_localized_timeField_with_inputformat(self):
# Parse a time in a valid format, get a parsed result
result = f.clean('1:30 PM')
- self.assertEqual(result, time(13,30,0))
+ self.assertEqual(result, time(13, 30, 0))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -309,11 +309,11 @@ def test_dateField(self):
self.assertRaises(forms.ValidationError, f.clean, '21/12/2010')
# ISO formats are accepted, even if not specified in formats.py
- self.assertEqual(f.clean('2010-12-21'), date(2010,12,21))
+ self.assertEqual(f.clean('2010-12-21'), date(2010, 12, 21))
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -321,7 +321,7 @@ def test_dateField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('21.12.10')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -335,7 +335,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -343,7 +343,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.10')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -359,7 +359,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -367,7 +367,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -383,7 +383,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# # Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -391,7 +391,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -408,7 +408,7 @@ def test_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -416,7 +416,7 @@ def test_dateField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('21-12-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -430,7 +430,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -438,7 +438,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21-12-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -453,7 +453,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -461,7 +461,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -476,7 +476,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# # Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -484,7 +484,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -499,7 +499,7 @@ def test_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('2010-12-21')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -507,7 +507,7 @@ def test_dateField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('12/21/2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -521,7 +521,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('2010-12-21')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -529,7 +529,7 @@ def test_localized_dateField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12/21/2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -543,7 +543,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -551,7 +551,7 @@ def test_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21-12-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -565,7 +565,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -573,7 +573,7 @@ def test_localized_dateField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21-12-2010')
- self.assertEqual(result, date(2010,12,21))
+ self.assertEqual(result, date(2010, 12, 21))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -595,11 +595,11 @@ def test_dateTimeField(self):
self.assertRaises(forms.ValidationError, f.clean, '1:30:05 PM 21/12/2010')
# ISO formats are accepted, even if not specified in formats.py
- self.assertEqual(f.clean('2010-12-21 13:30:05'), datetime(2010,12,21,13,30,5))
+ self.assertEqual(f.clean('2010-12-21 13:30:05'), datetime(2010, 12, 21, 13, 30, 5))
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -607,7 +607,7 @@ def test_dateTimeField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('21.12.2010 13:30')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -621,7 +621,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -629,7 +629,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('21.12.2010 13:30')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -645,7 +645,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('13.30.05 12.21.2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -653,7 +653,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('13.30 12-21-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -669,7 +669,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('13.30.05 12.21.2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# # Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -677,7 +677,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('13.30 12-21-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -694,7 +694,7 @@ def test_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30:05 PM 21/12/2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip
text = f.widget._format_value(result)
@@ -702,7 +702,7 @@ def test_dateTimeField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('1:30 PM 21-12-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -716,7 +716,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30:05 PM 21/12/2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -724,7 +724,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30 PM 21-12-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -739,7 +739,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -747,7 +747,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010 13:30')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -762,7 +762,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12.21.2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# # Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -770,7 +770,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12-21-2010 13:30')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -785,7 +785,7 @@ def test_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('2010-12-21 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -793,7 +793,7 @@ def test_dateTimeField(self):
# Parse a date in a valid, but non-default format, get a parsed result
result = f.clean('12/21/2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -807,7 +807,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('2010-12-21 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -815,7 +815,7 @@ def test_localized_dateTimeField(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('12/21/2010 13:30:05')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -829,7 +829,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30:05 PM 21.12.2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -837,7 +837,7 @@ def test_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30 PM 21-12-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
@@ -851,7 +851,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30:05 PM 21.12.2010')
- self.assertEqual(result, datetime(2010,12,21,13,30,5))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
# Check that the parsed result does a round trip to the same format
text = f.widget._format_value(result)
@@ -859,7 +859,7 @@ def test_localized_dateTimeField_with_inputformat(self):
# Parse a date in a valid format, get a parsed result
result = f.clean('1:30 PM 21-12-2010')
- self.assertEqual(result, datetime(2010,12,21,13,30))
+ self.assertEqual(result, datetime(2010, 12, 21, 13, 30))
# Check that the parsed result does a round trip to default format
text = f.widget._format_value(result)
View
172 tests/forms_tests/tests/test_media.py
@@ -14,7 +14,7 @@ class FormsMediaTestCase(TestCase):
def test_construction(self):
# Check construction of media objects
- m = Media(css={'all': ('path/to/css1','/path/to/css2')}, js=('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3'))
+ m = Media(css={'all': ('path/to/css1', '/path/to/css2')}, js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3'))
self.assertEqual(str(m), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/path/to/js1"></script>
@@ -23,9 +23,9 @@ def test_construction(self):
class Foo:
css = {
- 'all': ('path/to/css1','/path/to/css2')
+ 'all': ('path/to/css1', '/path/to/css2')
}
- js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
+ js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')
m3 = Media(Foo)
self.assertEqual(str(m3), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
@@ -52,9 +52,9 @@ def test_media_dsl(self):
class MyWidget1(TextInput):
class Media:
css = {
- 'all': ('path/to/css1','/path/to/css2')
+ 'all': ('path/to/css1', '/path/to/css2')
}
- js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
+ js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')
w1 = MyWidget1()
self.assertEqual(str(w1.media), """<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
@@ -77,23 +77,23 @@ def test_combine_media(self):
class MyWidget1(TextInput):
class Media:
css = {
- 'all': ('path/to/css1','/path/to/css2')
+ 'all': ('path/to/css1', '/path/to/css2')
}
- js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
+ js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')
class MyWidget2(TextInput):
class Media:
css = {
- 'all': ('/path/to/css2','/path/to/css3')
+ 'all': ('/path/to/css2', '/path/to/css3')
}
- js = ('/path/to/js1','/path/to/js4')
+ js = ('/path/to/js1', '/path/to/js4')
class MyWidget3(TextInput):
class Media:
css = {
- 'all': ('/path/to/css3','path/to/css1')
+ 'all': ('/path/to/css3', 'path/to/css1')
}
- js = ('/path/to/js1','/path/to/js4')
+ js = ('/path/to/js1', '/path/to/js4')
w1 = MyWidget1()
w2 = MyWidget2()
@@ -158,9 +158,9 @@ def test_media_property_parent_references(self):
class MyWidget1(TextInput):
class Media:
css = {
- 'all': ('path/to/css1','/path/to/css2')
+ 'all': ('path/to/css1', '/path/to/css2')
}
- js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
+ js = ('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3')
class MyWidget6(MyWidget1):