Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
flake8-clean the code a bit
Browse files Browse the repository at this point in the history
We still have a few ignored error codes and excluded folders left.
  • Loading branch information
matthiask committed Nov 17, 2013
1 parent fbfb58a commit 12adfd2
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -14,5 +14,5 @@ tests/test.zip
/docs/_build
/tests/.tox
/tests/.coverage
/tests/venv
/tests/htmlcov
venv
9 changes: 5 additions & 4 deletions docs/conf.py
Expand Up @@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -177,9 +178,9 @@

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'FeinCMS.tex', u'FeinCMS Documentation',
u'Feinheit GmbH and contributors', 'manual'),
latex_documents = [(
'index', 'FeinCMS.tex', u'FeinCMS Documentation',
u'Feinheit GmbH and contributors', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
2 changes: 1 addition & 1 deletion example/blog_urls.py
@@ -1,4 +1,4 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import patterns, url
from django.views import generic

from feincms.module.blog.models import Entry
Expand Down
Binary file modified example/example.db
Binary file not shown.
3 changes: 2 additions & 1 deletion example/manage.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import os, sys
import os
import sys

sys.path.insert(0,
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand Down
2 changes: 2 additions & 0 deletions example/models.py
Expand Up @@ -33,6 +33,7 @@
('default', 'Default position'),
))


def get_admin_fields(form, *args, **kwargs):
return {
'exclusive_subpages': forms.BooleanField(
Expand All @@ -43,6 +44,7 @@ def get_admin_fields(form, *args, **kwargs):
),
}


Page.create_content_type(ApplicationContent, APPLICATIONS=(
('blog_urls', 'Blog', {
'admin_fields': get_admin_fields,
Expand Down
2 changes: 1 addition & 1 deletion example/urls.py
Expand Up @@ -7,7 +7,7 @@
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls) ),
url(r'^admin/', include(admin.site.urls)),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(os.path.dirname(__file__), 'media/')}),
url(r'', include('feincms.contrib.preview.urls')),
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[flake8]
exclude=
exclude=venv,.tox
ignore=E501,E123,E124,E126,E128

[wheel]
Expand Down
3 changes: 2 additions & 1 deletion tests/manage.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import os, sys
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings")
Expand Down
1 change: 0 additions & 1 deletion tests/testapp/__init__.py
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion tests/testapp/applicationcontent_urls.py
Expand Up @@ -3,7 +3,7 @@
"""

from django import template
from django.conf.urls import patterns, include, url
from django.conf.urls import patterns, url
from django.http import HttpResponse, HttpResponseRedirect

from feincms.views.decorators import standalone
Expand Down
2 changes: 1 addition & 1 deletion tests/testapp/blog_urls.py
@@ -1,4 +1,4 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import patterns, url
from django.views import generic

from feincms.module.blog.models import Entry
Expand Down
2 changes: 2 additions & 0 deletions tests/testapp/models.py
Expand Up @@ -33,6 +33,7 @@
('default', 'Default position'),
))


def get_admin_fields(form, *args, **kwargs):
return {
'exclusive_subpages': forms.BooleanField(
Expand All @@ -43,6 +44,7 @@ def get_admin_fields(form, *args, **kwargs):
),
}


Page.create_content_type(ApplicationContent, APPLICATIONS=(
('testapp.blog_urls', 'Blog', {'admin_fields': get_admin_fields}),
('whatever', 'Test Urls', {'urls': 'testapp.applicationcontent_urls'}),
Expand Down
3 changes: 2 additions & 1 deletion tests/testapp/settings.py
Expand Up @@ -40,7 +40,8 @@
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request', # request context processor is needed
# request context processor is needed
'django.core.context_processors.request',
)

MIDDLEWARE_CLASSES = (
Expand Down
2 changes: 2 additions & 0 deletions tests/testapp/tests/__init__.py
Expand Up @@ -2,6 +2,8 @@
# coding=utf-8
# ------------------------------------------------------------------------

# flake8: noqa

from __future__ import absolute_import

from .test_cms import *
Expand Down
8 changes: 5 additions & 3 deletions tests/testapp/tests/test_cms.py
Expand Up @@ -12,13 +12,13 @@

from feincms.content.contactform.models import ContactFormContent
from feincms.content.file.models import FileContent
from feincms.content.image.models import ImageContent
from feincms.content.raw.models import RawContent
from feincms.content.richtext.models import RichTextContent
from feincms.content.video.models import VideoContent

from .test_stuff import ExampleCMSBase, Empty, ExampleCMSBase2


# ------------------------------------------------------------------------
class SubRawContent(RawContent):
title = models.CharField('title', max_length=100, blank=True)
Expand Down Expand Up @@ -55,6 +55,7 @@ def test_02_rsscontent_creation(self):
# Monkey-patch feedparser.parse to work with a local RSS dump so that
# the tests run faster.
_orig_parse = feedparser.parse

def _new_parse(link):
return _orig_parse(open(
os.path.join(os.path.dirname(__file__), 'yahoo.rss'), 'rb'))
Expand Down Expand Up @@ -154,9 +155,11 @@ class Attachment(models.Model):

class AnyContent(models.Model):
attachment = models.ForeignKey(Attachment, related_name='anycontents')

class Meta:
abstract = True
ct = ExampleCMSBase.create_content_type(AnyContent)

ExampleCMSBase.create_content_type(AnyContent)

self.assertTrue(hasattr(ExampleCMSBase, 'test_related_name'))
self.assertTrue(hasattr(Attachment, 'anycontents'))
Expand All @@ -172,4 +175,3 @@ def test_10_content_type_subclasses(self):
ct = ExampleCMSBase.content_type_for(RawContent)
ct2 = ExampleCMSBase.content_type_for(SubRawContent)
self.assertNotEqual(ct, ct2)

5 changes: 2 additions & 3 deletions tests/testapp/tests/test_extensions.py
@@ -1,10 +1,10 @@
# coding: utf-8

from __future__ import absolute_import

from django.contrib.sites.models import Site
from django.template.defaultfilters import slugify
from django.test.utils import override_settings
from django.test import TestCase
from django.contrib.sites.models import Site

from feincms.module.page.models import Page

Expand Down Expand Up @@ -32,7 +32,6 @@ def setUp(self):
self.page_de = de.parent
self.page_en = en.parent


def create_page(self, title='Test page', parent=None, **kwargs):
defaults = {
'template_key': 'base',
Expand Down
22 changes: 10 additions & 12 deletions tests/testapp/tests/test_page.py
Expand Up @@ -13,7 +13,6 @@
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.contenttypes.models import ContentType
from django.core import mail
from django.core.urlresolvers import reverse
from django.db import models
from django.contrib.sites.models import Site
from django.http import Http404, HttpResponseBadRequest
Expand Down Expand Up @@ -42,8 +41,8 @@

from .test_stuff import Empty

# ------------------------------------------------------------------------

# ------------------------------------------------------------------------
class PagesTestCase(TestCase):
def setUp(self):
u = User(username='test', is_active=True, is_staff=True, is_superuser=True)
Expand Down Expand Up @@ -769,28 +768,28 @@ def test_17_feincms_nav(self):

self.login()

self.create_page_through_admin('Page 1') # 1
self.create_page_through_admin('Page 1') # 1
self.create_page_through_admin('Page 1.1', 1)
self.create_page_through_admin('Page 1.2', 1) # 3
self.create_page_through_admin('Page 1.2', 1) # 3
self.create_page_through_admin('Page 1.2.1', 3)
self.create_page_through_admin('Page 1.2.2', 3)
self.create_page_through_admin('Page 1.2.3', 3)
self.create_page_through_admin('Page 1.3', 1)

self.create_page_through_admin('Page 2') # 8
self.create_page_through_admin('Page 2') # 8
self.create_page_through_admin('Page 2.1', 8)
self.create_page_through_admin('Page 2.2', 8)
self.create_page_through_admin('Page 2.3', 8)

self.create_page_through_admin('Page 3') # 12
self.create_page_through_admin('Page 3') # 12
self.create_page_through_admin('Page 3.1', 12)
self.create_page_through_admin('Page 3.2', 12)
self.create_page_through_admin('Page 3.3', 12) # 15
self.create_page_through_admin('Page 3.3.1', 15) # 16
self.create_page_through_admin('Page 3.3', 12) # 15
self.create_page_through_admin('Page 3.3.1', 15) # 16
self.create_page_through_admin('Page 3.3.1.1', 16)
self.create_page_through_admin('Page 3.3.2', 15)

self.create_page_through_admin('Page 4') # 19
self.create_page_through_admin('Page 4') # 19
self.create_page_through_admin('Page 4.1', 19)
self.create_page_through_admin('Page 4.2', 19)

Expand Down Expand Up @@ -1148,7 +1147,8 @@ def test_25_applicationcontent(self):

response = self.client.get(page.get_absolute_url() + 'response/')
self.assertContains(response, 'Anything')
self.assertContains(response, '<h2>Main content</h2>') # Ensure response has been wrapped
# Ensure response has been wrapped
self.assertContains(response, '<h2>Main content</h2>')

# Test standalone behavior
self.assertEqual(
Expand Down Expand Up @@ -1222,8 +1222,6 @@ def test_28_applicationcontent_reverse(self):
region='main', ordering=0,
urlconf_path='testapp.applicationcontent_urls')

from feincms.content.application.models import app_reverse, reverse

# test app_reverse
self.assertEqual(app_reverse('ac_module_root', 'testapp.applicationcontent_urls'),
page.get_absolute_url())
Expand Down
2 changes: 2 additions & 0 deletions tests/testapp/tests/test_stuff.py
Expand Up @@ -19,6 +19,7 @@
from feincms.module.page.models import Page
from feincms.utils import collect_dict_values, get_object, shorten_string


# ------------------------------------------------------------------------
class Empty(object):
"""
Expand All @@ -27,6 +28,7 @@ class Empty(object):

pass


class DocTest(TestCase):
def test_translation_short_language_code(self):
doctest.testmod(feincms.translations)
Expand Down
2 changes: 1 addition & 1 deletion tests/testapp/urls.py
Expand Up @@ -7,7 +7,7 @@
from feincms.module.page.sitemap import PageSitemap


sitemaps = {'pages' : PageSitemap}
sitemaps = {'pages': PageSitemap}

admin.autodiscover()

Expand Down

0 comments on commit 12adfd2

Please sign in to comment.