Permalink
Browse files

Fixing E302 Errors

Signed-off-by: Jason Myers <jason@jasonamyers.com>
  • Loading branch information...
1 parent 2a03a9a commit c3791463a5a9674f8e0148fbab57eae23c138896 @jasonamyers jasonamyers committed Nov 2, 2013
Showing with 748 additions and 96 deletions.
  1. +13 −1 django/forms/widgets.py
  2. +1 −1 setup.cfg
  3. +21 −15 tests/multiple_database/tests.py
  4. +1 −0 tests/mutually_referential/models.py
  5. +2 −0 tests/nested_foreign_keys/models.py
  6. +7 −0 tests/null_fk/models.py
  7. +4 −0 tests/null_fk_ordering/models.py
  8. +5 −0 tests/null_queries/models.py
  9. +7 −2 tests/one_to_one/models.py
  10. +1 −0 tests/one_to_one/tests.py
  11. +2 −0 tests/order_with_respect_to/models.py
  12. +1 −0 tests/ordering/models.py
  13. +5 −0 tests/prefetch_related/models.py
  14. +2 −0 tests/proxy_model_inheritance/models.py
  15. +26 −0 tests/proxy_models/models.py
  16. +91 −0 tests/queries/models.py
  17. +33 −11 tests/queries/tests.py
  18. +6 −0 tests/queryset_pickle/models.py
  19. +4 −0 tests/raw_query/models.py
  20. +1 −0 tests/responses/tests.py
  21. +2 −0 tests/reverse_lookup/models.py
  22. +2 −0 tests/reverse_single_related/models.py
  23. +10 −0 tests/select_related/models.py
  24. +2 −0 tests/select_related_onetoone/models.py
  25. +28 −0 tests/select_related_regress/models.py
  26. +8 −4 tests/serializers/tests.py
  27. +63 −0 tests/serializers_regress/models.py
  28. +36 −12 tests/serializers_regress/tests.py
  29. +1 −0 tests/servers/tests.py
  30. +1 −0 tests/settings_tests/tests.py
  31. +1 −0 tests/signals/models.py
  32. +2 −0 tests/signals/tests.py
  33. +1 −0 tests/signals_regress/models.py
  34. +1 −0 tests/signing/tests.py
  35. +6 −0 tests/sites_framework/models.py
  36. +1 −0 tests/staticfiles_tests/storage.py
  37. +1 −0 tests/str/models.py
  38. +5 −0 tests/string_lookup/models.py
  39. +1 −0 tests/syndication/tests.py
  40. +4 −0 tests/tablespaces/models.py
  41. +2 −0 tests/tablespaces/tests.py
  42. +9 −4 tests/template_tests/filters.py
  43. +2 −0 tests/template_tests/templatetags/bad_tag.py
  44. +49 −0 tests/template_tests/templatetags/custom.py
  45. +1 −0 tests/template_tests/templatetags/subpackage/echo.py
  46. +1 −0 tests/template_tests/test_callables.py
  47. +7 −6 tests/template_tests/test_loaders.py
  48. +2 −1 tests/template_tests/test_nodelist.py
  49. +3 −2 tests/template_tests/test_response.py
  50. +1 −0 tests/template_tests/test_smartif.py
  51. +22 −9 tests/template_tests/tests.py
  52. +5 −0 tests/template_tests/views.py
  53. +3 −1 tests/test_client/tests.py
  54. +22 −0 tests/test_client/views.py
  55. +1 −0 tests/test_client_regress/session.py
  56. +22 −6 tests/test_client_regress/tests.py
  57. +18 −0 tests/test_client_regress/views.py
  58. +1 −0 tests/test_runner/models.py
  59. +1 −0 tests/test_runner_deprecation_app/tests.py
  60. +1 −0 tests/test_utils/models.py
  61. +2 −0 tests/timezones/admin.py
  62. +5 −0 tests/timezones/forms.py
  63. +6 −0 tests/timezones/models.py
  64. +11 −5 tests/transactions/tests.py
  65. +2 −0 tests/transactions_regress/models.py
  66. +4 −1 tests/transactions_regress/tests.py
  67. +12 −1 tests/unmanaged_models/models.py
  68. +4 −0 tests/update/models.py
  69. +1 −0 tests/update_only_fields/models.py
  70. +1 −0 tests/urlpatterns_reverse/erroneous_views_module.py
  71. +5 −0 tests/urlpatterns_reverse/middleware.py
  72. +11 −1 tests/urlpatterns_reverse/tests.py
  73. +1 −0 tests/urlpatterns_reverse/urlconf_inner.py
  74. +10 −0 tests/urlpatterns_reverse/views.py
  75. +1 −0 tests/user_commands/management/commands/leave_locale_alone_false.py
  76. +1 −0 tests/user_commands/management/commands/leave_locale_alone_true.py
  77. +1 −0 tests/utils_tests/test_baseconv.py
  78. +1 −0 tests/utils_tests/test_checksums.py
  79. +1 −0 tests/utils_tests/test_datetime_safe.py
  80. +1 −0 tests/utils_tests/test_decorators.py
  81. +1 −0 tests/utils_tests/test_ipv6.py
  82. +3 −0 tests/utils_tests/test_jslex.py
  83. +5 −0 tests/utils_tests/test_module_loading.py
  84. +1 −0 tests/utils_tests/test_simplelazyobject.py
  85. +1 −0 tests/utils_tests/test_text.py
  86. +5 −4 tests/utils_tests/test_tzinfo.py
  87. +13 −0 tests/validation/models.py
  88. +1 −0 tests/validation/test_unique.py
  89. +2 −1 tests/validation/tests.py
  90. +6 −4 tests/validators/tests.py
  91. +1 −0 tests/version/tests.py
  92. +1 −0 tests/view_tests/__init__.py
  93. +5 −0 tests/view_tests/models.py
  94. +1 −0 tests/view_tests/templatetags/debugtags.py
  95. +5 −4 tests/view_tests/tests/test_debug.py
  96. +1 −0 tests/view_tests/tests/test_shortcuts.py
  97. +32 −0 tests/view_tests/views.py
  98. +1 −0 tests/wsgi/urls.py
@@ -104,6 +104,7 @@ def __add__(self, other):
getattr(combined, 'add_' + name)(getattr(other, '_' + name, None))
return combined
+
def media_property(cls):
def _media(self):
# Get the media property of the superclass, if it exists
@@ -131,6 +132,7 @@ def _media(self):
return base
return property(_media)
+
class MediaDefiningClass(type):
"""
Metaclass for classes that can have media definitions.
@@ -162,6 +164,7 @@ def __str__(self):
args.append(self.choices)
return self.parent_widget.render(*args)
+
class Widget(six.with_metaclass(MediaDefiningClass)):
is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
needs_multipart_form = False # Determines does this widget need multipart form
@@ -224,6 +227,7 @@ def id_for_label(self, id_):
"""
return id_
+
class Input(Widget):
"""
Base class for all <input> widgets (except type='checkbox' and
@@ -279,10 +283,12 @@ def render(self, name, value, attrs=None):
value = None
return super(PasswordInput, self).render(name, value, attrs)
+
class HiddenInput(Input):
input_type = 'hidden'
is_hidden = True
+
class MultipleHiddenInput(HiddenInput):
"""
A widget that handles <input type="hidden"> for fields that have a list
@@ -313,6 +319,7 @@ def value_from_datadict(self, data, files, name):
return data.getlist(name)
return data.get(name, None)
+
class FileInput(Input):
input_type = 'file'
needs_multipart_form = True
@@ -327,6 +334,7 @@ def value_from_datadict(self, data, files, name):
FILE_INPUT_CONTRADICTION = object()
+
class ClearableFileInput(FileInput):
initial_text = ugettext_lazy('Currently')
input_text = ugettext_lazy('Change')
@@ -379,7 +387,8 @@ def render(self, name, value, attrs=None):
def value_from_datadict(self, data, files, name):
upload = super(ClearableFileInput, self).value_from_datadict(data, files, name)
if not self.is_required and CheckboxInput().value_from_datadict(
- data, files, self.clear_checkbox_name(name)):
+ data, files, self.clear_checkbox_name(name)):
+
if upload:
# If the user contradicts themselves (uploads a new file AND
# checks the "clear" checkbox), we return a unique marker
@@ -389,6 +398,7 @@ def value_from_datadict(self, data, files, name):
return False
return upload
+
class Textarea(Widget):
def __init__(self, attrs=None):
# The 'rows' and 'cols' attributes are required for HTML correctness.
@@ -515,6 +525,7 @@ def render_options(self, choices, selected_choices):
output.append(self.render_option(selected_choices, option_value, option_label))
return '\n'.join(output)
+
class NullBooleanSelect(Select):
"""
A Select Widget intended to be used with NullBooleanField.
@@ -849,6 +860,7 @@ def decompress(self, value):
return [value.date(), value.time().replace(microsecond=0)]
return [None, None]
+
class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
"""
A Widget that splits datetime input into two <input type="hidden"> inputs.
View
@@ -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,./django/conf/app_template/*
-ignore=E124,E125,E127,E128,E226,E251,E302,E501,E261,W601
+ignore=E124,E125,E127,E128,E226,E251,E501,E261,W601
[metadata]
license-file = LICENSE
@@ -50,7 +50,8 @@ def test_default_creation(self):
except Book.DoesNotExist:
self.fail('"Pro Django" should exist on default database')
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.using('other').get,
title="Pro Django"
)
@@ -61,7 +62,8 @@ def test_default_creation(self):
except Book.DoesNotExist:
self.fail('"Dive into Python" should exist on default database')
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.using('other').get,
title="Dive into Python"
)
@@ -84,11 +86,13 @@ def test_other_creation(self):
except Book.DoesNotExist:
self.fail('"Pro Django" should exist on other database')
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.get,
title="Pro Django"
)
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.using('default').get,
title="Pro Django"
)
@@ -98,11 +102,13 @@ def test_other_creation(self):
except Book.DoesNotExist:
self.fail('"Dive into Python" should exist on other database')
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.get,
title="Dive into Python"
)
- self.assertRaises(Book.DoesNotExist,
+ self.assertRaises(
+ Book.DoesNotExist,
Book.objects.using('default').get,
title="Dive into Python"
)
@@ -164,25 +170,25 @@ def test_m2m_separation(self):
# Check that queries work across m2m joins
self.assertEqual(list(Book.objects.using('default').filter(authors__name='Marty Alchin').values_list('title', flat=True)),
- ['Pro Django'])
+ ['Pro Django'])
self.assertEqual(list(Book.objects.using('other').filter(authors__name='Marty Alchin').values_list('title', flat=True)),
- [])
+ [])
self.assertEqual(list(Book.objects.using('default').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)),
- [])
+ [])
self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)),
- ['Dive into Python'])
+ ['Dive into Python'])
# Reget the objects to clear caches
dive = Book.objects.using('other').get(title="Dive into Python")
mark = Person.objects.using('other').get(name="Mark Pilgrim")
# Retrive related object by descriptor. Related objects should be database-baound
self.assertEqual(list(dive.authors.all().values_list('name', flat=True)),
- ['Mark Pilgrim'])
+ ['Mark Pilgrim'])
self.assertEqual(list(mark.book_set.all().values_list('title', flat=True)),
- ['Dive into Python'])
+ ['Dive into Python'])
def test_m2m_forward_operations(self):
"M2M forward manipulations are all constrained to a single DB"
@@ -198,13 +204,13 @@ def test_m2m_forward_operations(self):
# Add a second author
john = Person.objects.using('other').create(name="John Smith")
self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)),
- [])
+ [])
dive.authors.add(john)
self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)),
- ['Dive into Python'])
+ ['Dive into Python'])
self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)),
- ['Dive into Python'])
+ ['Dive into Python'])
# Remove the second author
dive.authors.remove(john)
@@ -13,6 +13,7 @@ class Parent(models.Model):
# Use a simple string for forward declarations.
bestchild = models.ForeignKey("Child", null=True, related_name="favoured_by")
+
class Child(models.Model):
name = models.CharField(max_length=100)
@@ -17,12 +17,14 @@ class Event(models.Model):
class Screening(Event):
movie = models.ForeignKey(Movie)
+
class ScreeningNullFK(Event):
movie = models.ForeignKey(Movie, null=True)
class Package(models.Model):
screening = models.ForeignKey(Screening, null=True)
+
class PackageNullFK(models.Model):
screening = models.ForeignKey(ScreeningNullFK, null=True)
@@ -9,14 +9,17 @@
class SystemDetails(models.Model):
details = models.TextField()
+
class SystemInfo(models.Model):
system_details = models.ForeignKey(SystemDetails)
system_name = models.CharField(max_length=32)
+
class Forum(models.Model):
system_info = models.ForeignKey(SystemInfo)
forum_name = models.CharField(max_length=32)
+
@python_2_unicode_compatible
class Post(models.Model):
forum = models.ForeignKey(Forum, null=True)
@@ -25,6 +28,7 @@ class Post(models.Model):
def __str__(self):
return self.title
+
@python_2_unicode_compatible
class Comment(models.Model):
post = models.ForeignKey(Post, null=True)
@@ -38,12 +42,15 @@ def __str__(self):
# Ticket 15823
+
class Item(models.Model):
title = models.CharField(max_length=100)
+
class PropertyValue(models.Model):
label = models.CharField(max_length=100)
+
class Property(models.Model):
item = models.ForeignKey(Item, related_name='props')
key = models.CharField(max_length=100)
@@ -15,6 +15,7 @@
class Author(models.Model):
name = models.CharField(max_length=150)
+
@python_2_unicode_compatible
class Article(models.Model):
title = models.CharField(max_length=150)
@@ -31,10 +32,12 @@ class Meta:
class SystemInfo(models.Model):
system_name = models.CharField(max_length=32)
+
class Forum(models.Model):
system_info = models.ForeignKey(SystemInfo)
forum_name = models.CharField(max_length=32)
+
@python_2_unicode_compatible
class Post(models.Model):
forum = models.ForeignKey(Forum, null=True)
@@ -43,6 +46,7 @@ class Post(models.Model):
def __str__(self):
return self.title
+
@python_2_unicode_compatible
class Comment(models.Model):
post = models.ForeignKey(Post, null=True)
@@ -11,6 +11,7 @@ class Poll(models.Model):
def __str__(self):
return "Q: %s " % self.question
+
@python_2_unicode_compatible
class Choice(models.Model):
poll = models.ForeignKey(Poll)
@@ -20,12 +21,16 @@ def __str__(self):
return "Choice: %s in poll %s" % (self.choice, self.poll)
# A set of models with an inner one pointing to two outer ones.
+
+
class OuterA(models.Model):
pass
+
class OuterB(models.Model):
data = models.CharField(max_length=10)
+
class Inner(models.Model):
first = models.ForeignKey(OuterA)
# second would clash with the __second lookup.
@@ -19,6 +19,7 @@ class Place(models.Model):
def __str__(self):
return "%s the place" % self.name
+
@python_2_unicode_compatible
class Restaurant(models.Model):
place = models.OneToOneField(Place, primary_key=True)
@@ -28,6 +29,7 @@ class Restaurant(models.Model):
def __str__(self):
return "%s the restaurant" % self.place.name
+
@python_2_unicode_compatible
class Waiter(models.Model):
restaurant = models.ForeignKey(Restaurant)
@@ -36,13 +38,16 @@ class Waiter(models.Model):
def __str__(self):
return "%s the waiter at %s" % (self.name, self.restaurant)
+
class ManualPrimaryKey(models.Model):
primary_key = models.CharField(max_length=10, primary_key=True)
- name = models.CharField(max_length = 50)
+ name = models.CharField(max_length=50)
+
class RelatedModel(models.Model):
link = models.OneToOneField(ManualPrimaryKey)
- name = models.CharField(max_length = 50)
+ name = models.CharField(max_length=50)
+
@python_2_unicode_compatible
class MultiModel(models.Model):
@@ -6,6 +6,7 @@
from .models import (Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel,
MultiModel)
+
class OneToOneTests(TestCase):
def setUp(self):
@@ -10,6 +10,7 @@
class Question(models.Model):
text = models.CharField(max_length=200)
+
@python_2_unicode_compatible
class Answer(models.Model):
text = models.CharField(max_length=200)
@@ -21,6 +22,7 @@ class Meta:
def __str__(self):
return six.text_type(self.text)
+
@python_2_unicode_compatible
class Post(models.Model):
title = models.CharField(max_length=200)
@@ -28,6 +28,7 @@ class Meta:
def __str__(self):
return self.headline
+
@python_2_unicode_compatible
class ArticlePKOrdering(models.Model):
headline = models.CharField(max_length=100)
Oops, something went wrong. Retry.

0 comments on commit c379146

Please sign in to comment.