M .pre-commit-config.yaml => .pre-commit-config.yaml +5 -0
@@ 16,3 16,8 @@ repos:
hooks:
- id: black
language_version: python3
+
+ - repo: https://github.com/asottile/reorder_python_imports
+ rev: v2.3.0
+ hooks:
+ - id: reorder-python-imports
M .travis.yml => .travis.yml +2 -0
@@ 22,6 22,8 @@ matrix:
env: DJANGO="2.2"
- python: 3.6
env: DJANGO="3.0"
+ - python: 3.6
+ env: LINT=yes
- python: 3.7
env: DJANGO="2.2"
M docs/conf.py => docs/conf.py +2 -9
@@ 1,13 1,12 @@
import inspect
import os
import sys
+from datetime import datetime
import bleach
-
+import django
from django.utils.encoding import force_text
-from datetime import datetime
-
#
# django-wiki documentation build configuration file, created by
# sphinx-quickstart on Mon Jul 23 16:13:51 2012.
@@ 19,20 18,14 @@ from datetime import datetime
#
# All configuration values have a default; values that are commented out
# serve to show the default.
-
-
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
-
# -- General configuration -----------------------------------------------------
-
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
-import django
-
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
M setup.cfg => setup.cfg +4 -12
@@ 2,8 2,10 @@
universal = 0
[flake8]
-ignore = E501 W503 W504
-max-line-length = 160
+max-line-length = 213
+# black style
+extend-ignore = E203
+
max-complexity = 10
exclude = .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg,*/*migrations,testproject
@@ 12,13 14,3 @@ description-file = README.rst
[aliases]
test=pytest
-
-[isort]
-combine_as_imports = true
-default_section = THIRDPARTY
-include_trailing_comma = true
-line_length = 160
-multi_line_output = 5
-not_skip = __init__.py
-skip = docs/conf.py
-indent = 4
M setup.py => setup.py +5 -4
@@ 1,11 1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
import os
import sys
from glob import glob
-from setuptools import find_packages, setup
+from setuptools import find_packages
+from setuptools import setup
sys.path.append(os.path.join(os.path.dirname(__file__), "src"))
@@ 42,14 42,15 @@ test_requirements = [
test_lint_requirements = [
"flake8>=3.7,<3.8",
- "flake8-isort",
+ "black", # Just use the latest
+ "pre-commit",
]
setup_requirements = [
"pytest-runner",
]
-development_requirements = test_requirements + test_lint_requirements + ["pre-commit"]
+development_requirements = test_requirements + test_lint_requirements
extras_requirements = {
"devel": development_requirements,
M src/wiki/__init__.py => src/wiki/__init__.py +0 -2
@@ 13,8 13,6 @@
#
# You should have received a copy of the GNU General Public License
# along with django-wiki. If not, see <http://www.gnu.org/licenses/>.
-
-
from wiki.core.version import get_version
default_app_config = "wiki.apps.WikiConfig"
M src/wiki/admin.py => src/wiki/admin.py +2 -1
@@ 4,7 4,8 @@ from django.contrib.contenttypes.admin import GenericTabularInline
from django.utils.translation import gettext_lazy as _
from mptt.admin import MPTTModelAdmin
-from . import editors, models
+from . import editors
+from . import models
class ArticleObjectAdmin(GenericTabularInline):
M src/wiki/conf/settings.py => src/wiki/conf/settings.py +1 -1
@@ 52,7 52,7 @@ MARKDOWN_KWARGS = {
"markdown.extensions.abbr",
"markdown.extensions.sane_lists",
],
- "extension_configs": {"wiki.plugins.macros.mdx.toc": {"title": _("Contents")},},
+ "extension_configs": {"wiki.plugins.macros.mdx.toc": {"title": _("Contents")}},
}
MARKDOWN_KWARGS.update(getattr(django_settings, "WIKI_MARKDOWN_KWARGS", {}))
M src/wiki/core/diff.py => src/wiki/core/diff.py +1 -1
@@ 6,6 6,6 @@ def simple_merge(txt1, txt2):
differ = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
diff = differ.compare(txt1.splitlines(1), txt2.splitlines(1))
- content = "".join([l[2:] for l in diff])
+ content = "".join([_l[2:] for _l in diff])
return content
M src/wiki/core/markdown/__init__.py => src/wiki/core/markdown/__init__.py +5 -1
@@ 39,7 39,11 @@ class ArticleMarkdown(markdown.Markdown):
attrs.update(plugin_registry.get_html_attributes().items())
html = bleach.clean(
- html, tags=tags, attributes=attrs, styles=settings.MARKDOWN_HTML_STYLES, strip=True
+ html,
+ tags=tags,
+ attributes=attrs,
+ styles=settings.MARKDOWN_HTML_STYLES,
+ strip=True,
)
return html
M src/wiki/core/markdown/mdx/codehilite.py => src/wiki/core/markdown/mdx/codehilite.py +2 -1
@@ 1,7 1,8 @@
import logging
import re
-from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension
+from markdown.extensions.codehilite import CodeHilite
+from markdown.extensions.codehilite import CodeHiliteExtension
from markdown.preprocessors import Preprocessor
from markdown.treeprocessors import Treeprocessor
M src/wiki/decorators.py => src/wiki/decorators.py +8 -9
@@ 1,11 1,10 @@
from functools import wraps
-from django.http import (
- HttpResponseForbidden,
- HttpResponseNotFound,
- HttpResponseRedirect,
-)
-from django.shortcuts import get_object_or_404, redirect
+from django.http import HttpResponseForbidden
+from django.http import HttpResponseNotFound
+from django.http import HttpResponseRedirect
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.http import urlquote
@@ 36,10 35,10 @@ def response_forbidden(request, article, urlpath, read_denied=False):
# TODO: This decorator is too complex (C901)
-def get_article(
+def get_article( # noqa: max-complexity=23
func=None,
can_read=True,
- can_write=False, # noqa: max-complexity=13
+ can_write=False,
deleted_contents=False,
not_locked=False,
can_delete=False,
@@ 89,7 88,7 @@ def get_article(
path = "/".join(pathlist[:-1])
parent = models.URLPath.get_by_path(path)
return HttpResponseRedirect(
- reverse("wiki:create", kwargs={"path": parent.path,})
+ reverse("wiki:create", kwargs={"path": parent.path})
+ "?slug=%s" % pathlist[-1].lower()
)
except models.URLPath.DoesNotExist:
M src/wiki/forms_account_handling.py => src/wiki/forms_account_handling.py +2 -1
@@ 6,7 6,8 @@ from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import UserCreationForm
from django.core.exceptions import FieldDoesNotExist
-from django.db.models.fields import CharField, EmailField
+from django.db.models.fields import CharField
+from django.db.models.fields import EmailField
from django.utils.translation import gettext_lazy as _
from wiki.conf import settings
M src/wiki/managers.py => src/wiki/managers.py +4 -2
@@ 1,6 1,8 @@
from django.db import models
-from django.db.models import Count, Q
-from django.db.models.query import EmptyQuerySet, QuerySet
+from django.db.models import Count
+from django.db.models import Q
+from django.db.models.query import EmptyQuerySet
+from django.db.models.query import QuerySet
from mptt.managers import TreeManager
M src/wiki/migrations/0001_initial.py => src/wiki/migrations/0001_initial.py +2 -1
@@ 1,7 1,8 @@
import django.db.models.deletion
import mptt.fields
from django.conf import settings
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
from django.db.models.fields import GenericIPAddressField as IPAddressField
from wiki.conf.settings import GROUP_MODEL
M src/wiki/migrations/0003_mptt_upgrade.py => src/wiki/migrations/0003_mptt_upgrade.py +2 -2
@@ 1,8 1,8 @@
# Upgrades fields changed in django-mptt
# See: https://github.com/django-mptt/django-mptt/pull/578
# Generated by Django 2.2.7 on 2020-02-06 20:36
-
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/models/__init__.py => src/wiki/models/__init__.py +2 -1
@@ 1,4 1,5 @@
-from django import shortcuts, urls
+from django import shortcuts
+from django import urls
from django.urls import base
from django.utils.functional import lazy
M src/wiki/models/article.py => src/wiki/models/article.py +3 -1
@@ 4,7 4,9 @@ from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.db import models
from django.db.models.fields import GenericIPAddressField as IPAddressField
-from django.db.models.signals import post_save, pre_delete, pre_save
+from django.db.models.signals import post_save
+from django.db.models.signals import pre_delete
+from django.db.models.signals import pre_save
from django.urls import reverse
from django.utils import translation
from django.utils.safestring import mark_safe
M src/wiki/models/pluginbase.py => src/wiki/models/pluginbase.py +2 -1
@@ 23,7 23,8 @@ from django.db.models import signals
from django.utils.translation import gettext_lazy as _
from wiki.decorators import disable_signal_for_loaddata
-from .article import ArticleRevision, BaseRevisionMixin
+from .article import ArticleRevision
+from .article import BaseRevisionMixin
__all__ = [
"ArticlePlugin",
M src/wiki/models/urlpath.py => src/wiki/models/urlpath.py +11 -5
@@ 5,17 5,23 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
-from django.db import models, transaction
-from django.db.models.signals import post_save, pre_delete
+from django.db import models
+from django.db import transaction
+from django.db.models.signals import post_save
+from django.db.models.signals import pre_delete
from django.urls import reverse
-from django.utils.translation import gettext, gettext_lazy as _
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel
from wiki import managers
from wiki.conf import settings
-from wiki.core.exceptions import MultipleRootURLs, NoRootURL
+from wiki.core.exceptions import MultipleRootURLs
+from wiki.core.exceptions import NoRootURL
from wiki.decorators import disable_signal_for_loaddata
-from wiki.models.article import Article, ArticleForObject, ArticleRevision
+from wiki.models.article import Article
+from wiki.models.article import ArticleForObject
+from wiki.models.article import ArticleRevision
__all__ = [
"URLPath",
M src/wiki/plugins/attachments/forms.py => src/wiki/plugins/attachments/forms.py +2 -1
@@ 3,7 3,8 @@ import zipfile
from django import forms
from django.core.files.uploadedfile import File
-from django.utils.translation import gettext, gettext_lazy as _
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
from wiki.core.permissions import can_moderate
from wiki.plugins.attachments import models
from wiki.plugins.attachments.models import IllegalFileExtension
M src/wiki/plugins/attachments/migrations/0001_initial.py => src/wiki/plugins/attachments/migrations/0001_initial.py +2 -1
@@ 1,7 1,8 @@
import django.db.models.deletion
import wiki.plugins.attachments.models
from django.conf import settings
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
from django.db.models.fields import GenericIPAddressField as IPAddressField
M src/wiki/plugins/attachments/migrations/0002_auto_20151118_1816.py => src/wiki/plugins/attachments/migrations/0002_auto_20151118_1816.py +2 -1
@@ 1,4 1,5 @@
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/plugins/attachments/models.py => src/wiki/plugins/attachments/models.py +2 -1
@@ 3,7 3,8 @@ import os
from django.conf import settings as django_settings
from django.db import models
from django.db.models import signals
-from django.utils.translation import gettext, gettext_lazy as _
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
from wiki import managers
from wiki.decorators import disable_signal_for_loaddata
from wiki.models.article import BaseRevisionMixin
M src/wiki/plugins/attachments/views.py => src/wiki/plugins/attachments/views.py +13 -5
@@ 1,15 1,23 @@
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
-from django.http import Http404, HttpResponseRedirect
-from django.shortcuts import get_object_or_404, redirect
+from django.http import Http404
+from django.http import HttpResponseRedirect
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
-from django.views.generic import FormView, ListView, TemplateView, View
+from django.views.generic import FormView
+from django.views.generic import ListView
+from django.views.generic import TemplateView
+from django.views.generic import View
from wiki.core.http import send_file
from wiki.core.paginator import WikiPaginator
-from wiki.decorators import get_article, response_forbidden
-from wiki.plugins.attachments import forms, models, settings
+from wiki.decorators import get_article
+from wiki.decorators import response_forbidden
+from wiki.plugins.attachments import forms
+from wiki.plugins.attachments import models
+from wiki.plugins.attachments import settings
from wiki.views.mixins import ArticleMixin
M src/wiki/plugins/attachments/wiki_plugin.py => src/wiki/plugins/attachments/wiki_plugin.py +5 -2
@@ 1,8 1,11 @@
-from django.urls import include, re_path
+from django.urls import include
+from django.urls import re_path
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from wiki.plugins.attachments import models, settings, views
+from wiki.plugins.attachments import models
+from wiki.plugins.attachments import settings
+from wiki.plugins.attachments import views
from wiki.plugins.attachments.markdown_extensions import AttachmentExtension
from wiki.plugins.notifications.settings import ARTICLE_EDIT
from wiki.plugins.notifications.util import truncate_title
M src/wiki/plugins/editsection/markdown_extensions.py => src/wiki/plugins/editsection/markdown_extensions.py +4 -4
@@ 61,8 61,8 @@ class EditSectionProcessor(Treeprocessor):
if level <= sec_level:
return sec_start, self.headers[cur_header].start
- for l in range(level, last_level):
- cur_pos[l] = 0
+ for _l in range(level, last_level):
+ cur_pos[_l] = 0
cur_pos[level - 1] += 1
last_level = level
@@ 92,8 92,8 @@ class EditSectionProcessor(Treeprocessor):
continue
level = int(match.group(1))
- for l in range(level, last_level):
- cur_pos[l] = 0
+ for _l in range(level, last_level):
+ cur_pos[_l] = 0
cur_pos[level - 1] += 1
last_level = level
location = "-".join(map(str, cur_pos))
M src/wiki/plugins/editsection/views.py => src/wiki/plugins/editsection/views.py +5 -4
@@ 1,7 1,8 @@
import re
from django.contrib import messages
-from django.shortcuts import get_object_or_404, redirect
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.utils.translation import gettext_lazy
from wiki import models
@@ 131,7 132,7 @@ class EditSection(EditView):
request.session["editsection_content"] = self.orig_section
else:
messages.error(
- request, " ".format(ERROR_SECTION_CHANGED, ERROR_TRY_AGAIN)
+ request, "{} {}".format(ERROR_SECTION_CHANGED, ERROR_TRY_AGAIN)
)
return self._redirect_to_article()
else:
@@ 157,7 158,7 @@ class EditSection(EditView):
if self.orig_section != text[location[0] : location[1]]:
messages.warning(
self.request,
- " ".format(
+ "{} {} {}".format(
ERROR_SECTION_CHANGED, ERROR_SECTION_UNSAVED, ERROR_TRY_AGAIN
),
)
@@ 173,7 174,7 @@ class EditSection(EditView):
)
self.article.save()
messages.error(
- self.request, " ".format(ERROR_ARTICLE_CHANGED, ERROR_TRY_AGAIN)
+ self.request, "{} {}".format(ERROR_ARTICLE_CHANGED, ERROR_TRY_AGAIN)
)
return self._redirect_to_article()
M src/wiki/plugins/editsection/wiki_plugin.py => src/wiki/plugins/editsection/wiki_plugin.py +2 -1
@@ 3,7 3,8 @@ from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.editsection.markdown_extensions import EditSectionExtension
-from . import settings, views
+from . import settings
+from . import views
class EditSectionPlugin(BasePlugin):
M src/wiki/plugins/globalhistory/wiki_plugin.py => src/wiki/plugins/globalhistory/wiki_plugin.py +2 -1
@@ 2,7 2,8 @@ from django.urls import re_path
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from . import settings, views
+from . import settings
+from . import views
class GlobalHistoryPlugin(BasePlugin):
M src/wiki/plugins/images/forms.py => src/wiki/plugins/images/forms.py +2 -1
@@ 1,5 1,6 @@
from django import forms
-from django.utils.translation import gettext, gettext_lazy as _
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
from wiki.core.plugins.base import PluginSidebarFormMixin
from wiki.plugins.images import models
M src/wiki/plugins/images/markdown_extensions.py => src/wiki/plugins/images/markdown_extensions.py +2 -1
@@ 1,6 1,7 @@
import markdown
from django.template.loader import render_to_string
-from wiki.plugins.images import models, settings
+from wiki.plugins.images import models
+from wiki.plugins.images import settings
IMAGE_RE = (
r"(?:(?im)"
M src/wiki/plugins/images/migrations/0001_initial.py => src/wiki/plugins/images/migrations/0001_initial.py +2 -1
@@ 1,5 1,6 @@
import wiki.plugins.images.models
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/plugins/images/migrations/0002_auto_20151118_1811.py => src/wiki/plugins/images/migrations/0002_auto_20151118_1811.py +2 -1
@@ 1,4 1,5 @@
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/plugins/images/models.py => src/wiki/plugins/images/models.py +5 -3
@@ 3,8 3,10 @@ import os.path
from django.conf import settings as django_settings
from django.db import models
from django.db.models import signals
-from django.utils.translation import gettext, gettext_lazy as _
-from wiki.models.pluginbase import RevisionPlugin, RevisionPluginRevision
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
+from wiki.models.pluginbase import RevisionPlugin
+from wiki.models.pluginbase import RevisionPluginRevision
from . import settings
@@ 115,7 117,7 @@ class ImageRevision(RevisionPluginRevision):
return gettext("Current revision not set!!")
-def on_image_revision_delete(instance, *args, **kwargs):
+def on_image_revision_delete(instance, *args, **kwargs): # noqa: max-complexity=11
if not instance.image:
return
M src/wiki/plugins/images/templatetags/wiki_images_tags.py => src/wiki/plugins/images/templatetags/wiki_images_tags.py +2 -1
@@ 1,5 1,6 @@
from django import template
-from wiki.plugins.images import models, settings
+from wiki.plugins.images import models
+from wiki.plugins.images import settings
register = template.Library()
M src/wiki/plugins/images/views.py => src/wiki/plugins/images/views.py +8 -4
@@ 1,16 1,20 @@
import logging
from django.contrib import messages
-from django.shortcuts import get_object_or_404, redirect
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
-from django.views.generic import FormView, ListView, RedirectView
+from django.views.generic import FormView
+from django.views.generic import ListView
+from django.views.generic import RedirectView
from wiki.conf import settings as wiki_settings
from wiki.core.paginator import WikiPaginator
from wiki.decorators import get_article
from wiki.models.pluginbase import RevisionPluginRevision
-from wiki.plugins.images import forms, models
+from wiki.plugins.images import forms
+from wiki.plugins.images import models
from wiki.views.mixins import ArticleMixin
logger = logging.getLogger(__name__)
@@ 192,7 196,7 @@ class RevisionAddView(ArticleMixin, FormView):
messages.info(
self.request,
_("%(file)s has been saved.")
- % {"file": self.image.current_revision.imagerevision.get_filename(),},
+ % {"file": self.image.current_revision.imagerevision.get_filename()},
)
if self.urlpath:
return redirect("wiki:edit", path=self.urlpath.path)
M src/wiki/plugins/images/wiki_plugin.py => src/wiki/plugins/images/wiki_plugin.py +4 -1
@@ 2,7 2,10 @@ from django.urls import re_path
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from wiki.plugins.images import forms, models, settings, views
+from wiki.plugins.images import forms
+from wiki.plugins.images import models
+from wiki.plugins.images import settings
+from wiki.plugins.images import views
from wiki.plugins.images.markdown_extensions import ImageExtension
from wiki.plugins.notifications.settings import ARTICLE_EDIT
from wiki.plugins.notifications.util import truncate_title
M src/wiki/plugins/links/wiki_plugin.py => src/wiki/plugins/links/wiki_plugin.py +4 -2
@@ 1,8 1,10 @@
-from django.urls import re_path, reverse_lazy
+from django.urls import re_path
+from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from wiki.plugins.links import settings, views
+from wiki.plugins.links import settings
+from wiki.plugins.links import views
from wiki.plugins.links.mdx.djangowikilinks import WikiPathExtension
from wiki.plugins.links.mdx.urlize import makeExtension as urlize_makeExtension
M src/wiki/plugins/macros/mdx/toc.py => src/wiki/plugins/macros/mdx/toc.py +3 -3
@@ 1,6 1,6 @@
-import re
-
-from markdown.extensions.toc import TocExtension, TocTreeprocessor, slugify
+from markdown.extensions.toc import slugify
+from markdown.extensions.toc import TocExtension
+from markdown.extensions.toc import TocTreeprocessor
from wiki.plugins.macros import settings
HEADER_ID_PREFIX = "wiki-toc-"
M src/wiki/plugins/macros/mdx/wikilinks.py => src/wiki/plugins/macros/mdx/wikilinks.py +2 -1
@@ 5,7 5,8 @@ import re
import markdown
from django.urls import reverse
-from markdown.extensions import Extension, wikilinks
+from markdown.extensions import Extension
+from markdown.extensions import wikilinks
def build_url(label, base, end, md):
M src/wiki/plugins/notifications/forms.py => src/wiki/plugins/notifications/forms.py +7 -3
@@ 1,9 1,13 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
-from django.forms.models import BaseModelFormSet, modelformset_factory
+from django.forms.models import BaseModelFormSet
+from django.forms.models import modelformset_factory
from django.utils.safestring import mark_safe
-from django.utils.translation import gettext, gettext_lazy as _
-from django_nyt.models import NotificationType, Settings, Subscription
+from django.utils.translation import gettext
+from django.utils.translation import gettext_lazy as _
+from django_nyt.models import NotificationType
+from django_nyt.models import Settings
+from django_nyt.models import Subscription
from wiki.core.plugins.base import PluginSettingsFormMixin
from wiki.plugins.notifications import models
from wiki.plugins.notifications.settings import ARTICLE_EDIT
M src/wiki/plugins/notifications/migrations/0001_initial.py => src/wiki/plugins/notifications/migrations/0001_initial.py +2 -1
@@ 1,4 1,5 @@
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/plugins/notifications/migrations/0002_auto_20151118_1811.py => src/wiki/plugins/notifications/migrations/0002_auto_20151118_1811.py +2 -1
@@ 1,4 1,5 @@
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M src/wiki/plugins/notifications/views.py => src/wiki/plugins/notifications/views.py +2 -1
@@ 5,7 5,8 @@ from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.generic import FormView
-from . import forms, models
+from . import forms
+from . import models
class NotificationSettings(FormView):
M src/wiki/plugins/notifications/wiki_plugin.py => src/wiki/plugins/notifications/wiki_plugin.py +2 -1
@@ 2,7 2,8 @@ from django.urls import re_path
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from . import settings, views
+from . import settings
+from . import views
class NotifyPlugin(BasePlugin):
M src/wiki/plugins/redlinks/mdx/redlinks.py => src/wiki/plugins/redlinks/mdx/redlinks.py +2 -1
@@ 1,5 1,6 @@
import html
-from urllib.parse import urljoin, urlparse
+from urllib.parse import urljoin
+from urllib.parse import urlparse
from markdown.extensions import Extension
from markdown.postprocessors import AndSubstitutePostprocessor
M src/wiki/sites.py => src/wiki/sites.py +2 -1
@@ 1,5 1,6 @@
from django.apps import apps
-from django.urls import include, re_path
+from django.urls import include
+from django.urls import re_path
from django.utils.functional import LazyObject
from django.utils.module_loading import import_string
from wiki.conf import settings
M src/wiki/urls.py => src/wiki/urls.py +5 -2
@@ 1,9 1,12 @@
-from django.urls import include, re_path
+from django.urls import include
+from django.urls import re_path
from django.utils.module_loading import import_string
from wiki import sites
from wiki.conf import settings
from wiki.core.plugins import registry
-from wiki.views import accounts, article, deleted_list
+from wiki.views import accounts
+from wiki.views import article
+from wiki.views import deleted_list
urlpatterns = [
re_path(r"^", sites.site.urls),
M src/wiki/views/accounts.py => src/wiki/views/accounts.py +10 -8
@@ 8,19 8,21 @@ settings.WIKI_SIGNUP_URL = '/your/signup/url'
SETTINGS.LOGIN_URL
SETTINGS.LOGOUT_URL
"""
-
from django.conf import settings as django_settings
from django.contrib import messages
-from django.contrib.auth import (
- get_user_model,
- login as auth_login,
- logout as auth_logout,
-)
+from django.contrib.auth import get_user_model
+from django.contrib.auth import login as auth_login
+from django.contrib.auth import logout as auth_logout
from django.contrib.auth.forms import AuthenticationForm
-from django.shortcuts import get_object_or_404, redirect, render
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
+from django.shortcuts import render
from django.urls import reverse
from django.utils.translation import gettext as _
-from django.views.generic import CreateView, FormView, UpdateView, View
+from django.views.generic import CreateView
+from django.views.generic import FormView
+from django.views.generic import UpdateView
+from django.views.generic import View
from wiki import forms
from wiki.conf import settings
M src/wiki/views/article.py => src/wiki/views/article.py +15 -12
@@ 7,20 7,23 @@ from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.db.models import Q
from django.http import Http404
-from django.shortcuts import get_object_or_404, redirect, render
+from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect
+from django.shortcuts import render
from django.urls import reverse
from django.utils.decorators import method_decorator
-from django.utils.translation import gettext as _, ngettext
+from django.utils.translation import gettext as _
+from django.utils.translation import ngettext
from django.views.decorators.clickjacking import xframe_options_sameorigin
-from django.views.generic import (
- DetailView,
- FormView,
- ListView,
- RedirectView,
- TemplateView,
- View,
-)
-from wiki import editors, forms, models
+from django.views.generic import DetailView
+from django.views.generic import FormView
+from django.views.generic import ListView
+from django.views.generic import RedirectView
+from django.views.generic import TemplateView
+from django.views.generic import View
+from wiki import editors
+from wiki import forms
+from wiki import models
from wiki.conf import settings
from wiki.core import permissions
from wiki.core.diff import simple_merge
@@ 820,7 823,7 @@ class ChangeRevisionView(RedirectView):
_(
"The article %(title)s is now set to display revision #%(revision_number)d"
)
- % {"title": revision.title, "revision_number": revision.revision_number,},
+ % {"title": revision.title, "revision_number": revision.revision_number},
)
M testproject/testproject/settings/base.py => testproject/testproject/settings/base.py +0 -1
@@ 7,7 7,6 @@ https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
-
import os
from django.urls import reverse_lazy
M testproject/testproject/settings/local.py => testproject/testproject/settings/local.py +0 -2
@@ 1,6 1,4 @@
# Add your own changes here -- but do not push to remote!!
# After changing the file, from root of repository execute:
-
# git update-index --assume-unchanged testproject/testproject/settings/local.py
-
from .dev import * # noqa @UnusedWildImport
M testproject/testproject/urls.py => testproject/testproject/urls.py +5 -5
@@ 2,8 2,9 @@ from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.http.response import HttpResponse
+from django.urls import include
+from django.urls import re_path
from django.views.static import serve as static_serve
-from django.urls import include, re_path
admin.autodiscover()
@@ 25,14 26,13 @@ if settings.DEBUG:
if settings.DEBUG:
try:
import debug_toolbar
- urlpatterns = [
- re_path('__debug__/', include(debug_toolbar.urls)),
+ urlpatterns = [
+ re_path("__debug__/", include(debug_toolbar.urls)),
# For django versions before 2.0:
# url(r'^__debug__/', include(debug_toolbar.urls)),
-
] + urlpatterns
- except ImportError as ie:
+ except ImportError:
pass
urlpatterns += [
M testproject/testproject/wsgi.py => testproject/testproject/wsgi.py +2 -1
@@ 16,10 16,11 @@ framework.
import os
import sys
+from django.core.wsgi import get_wsgi_application
+
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
-from django.core.wsgi import get_wsgi_application
PROJECT_PATH = os.path.abspath(os.path.split(__file__)[0])
PROJECT_PARENT = os.path.abspath(os.path.split(PROJECT_PATH)[0])
M tests/base.py => tests/base.py +4 -2
@@ 3,8 3,10 @@ import unittest
import django_functest
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
-from django.template import Context, Template
-from django.test import TestCase, override_settings
+from django.template import Context
+from django.template import Template
+from django.test import override_settings
+from django.test import TestCase
from django.urls import reverse
from wiki.models import URLPath
M tests/core/test_accounts.py => tests/core/test_accounts.py +10 -10
@@ 6,15 6,13 @@ from django.shortcuts import resolve_url
from wiki.conf import settings as wiki_settings
from wiki.models import reverse
-from ..base import (
- SUPERUSER1_PASSWORD,
- SUPERUSER1_USERNAME,
- ArticleWebTestUtils,
- DjangoClientTestBase,
- RequireRootArticleMixin,
- TestBase,
- wiki_override_settings,
-)
+from ..base import ArticleWebTestUtils
+from ..base import DjangoClientTestBase
+from ..base import RequireRootArticleMixin
+from ..base import SUPERUSER1_PASSWORD
+from ..base import SUPERUSER1_USERNAME
+from ..base import TestBase
+from ..base import wiki_override_settings
from ..testdata.models import CustomUser
@@ 38,7 36,9 @@ class AccountUpdateTest(
# save a new revision
response = self.client.post(resolve_url("wiki:profile_update"), example_data)
- self.assertContains(response, "Passwords don", status_code=200) # Django 2/3 output different escaped versions of single quote in don't
+ self.assertContains(
+ response, "Passwords don", status_code=200
+ ) # Django 2/3 output different escaped versions of single quote in don't
# Now check that we don't succeed with unmatching passwords
example_data = {
M tests/core/test_basic.py => tests/core/test_basic.py +3 -1
@@ 5,7 5,9 @@ from django.test import TestCase
from wiki.conf import settings as wiki_settings
from wiki.core.http import send_file
from wiki.forms import Group
-from wiki.models import Article, ArticleRevision, URLPath
+from wiki.models import Article
+from wiki.models import ArticleRevision
+from wiki.models import URLPath
from ..base import wiki_override_settings
from ..testdata.models import CustomGroup
M tests/core/test_checks.py => tests/core/test_checks.py +6 -7
@@ 1,14 1,13 @@
import copy
from django.conf import settings
-from django.core.checks import Error, registry
+from django.core.checks import Error
+from django.core.checks import registry
from django.test import TestCase
-from wiki.checks import (
- FIELDS_IN_CUSTOM_USER_MODEL,
- REQUIRED_CONTEXT_PROCESSORS,
- REQUIRED_INSTALLED_APPS,
- Tags,
-)
+from wiki.checks import FIELDS_IN_CUSTOM_USER_MODEL
+from wiki.checks import REQUIRED_CONTEXT_PROCESSORS
+from wiki.checks import REQUIRED_INSTALLED_APPS
+from wiki.checks import Tags
from ..base import wiki_override_settings
M tests/core/test_forms.py => tests/core/test_forms.py +5 -2
@@ 1,7 1,10 @@
from django.test import TestCase
from django.utils.translation import gettext
-from tests.base import DjangoClientTestBase, RequireRootArticleMixin
-from wiki.forms import DeleteForm, UserCreationForm
+from wiki.forms import DeleteForm
+from wiki.forms import UserCreationForm
+
+from tests.base import DjangoClientTestBase
+from tests.base import RequireRootArticleMixin
class DeleteFormTests(RequireRootArticleMixin, DjangoClientTestBase):
M tests/core/test_managers.py => tests/core/test_managers.py +2 -1
@@ 4,7 4,8 @@ because the pattern of building them is different from Django
1.5 to 1.6 to 1.7 so there will be 3 patterns in play at the
same time.
"""
-from wiki.models import Article, URLPath
+from wiki.models import Article
+from wiki.models import URLPath
from wiki.plugins.attachments.models import Attachment
from ..base import ArticleTestBase
M tests/core/test_models.py => tests/core/test_models.py +3 -1
@@ 5,7 5,9 @@ from django.test.testcases import TestCase
from django.urls import re_path
from wiki.conf import settings
from wiki.managers import ArticleManager
-from wiki.models import Article, ArticleRevision, URLPath
+from wiki.models import Article
+from wiki.models import ArticleRevision
+from wiki.models import URLPath
from wiki.urls import WikiURLPatterns
User = get_user_model()
M tests/core/test_sites.py => tests/core/test_sites.py +6 -3
@@ 2,10 2,13 @@ from importlib import reload
from django.contrib.sites.models import Site
from django.test.testcases import TestCase
-from django.urls import include, re_path
-from wiki import sites, urls
+from django.urls import include
+from django.urls import re_path
+from wiki import sites
+from wiki import urls
from wiki.apps import WikiConfig
-from wiki.models import Article, URLPath
+from wiki.models import Article
+from wiki.models import URLPath
from ..base import wiki_override_settings
M tests/core/test_template_filters.py => tests/core/test_template_filters.py +11 -11
@@ 1,15 1,15 @@
from django.contrib.auth import get_user_model
-from wiki.models import Article, ArticleRevision
-from wiki.templatetags.wiki_tags import (
- can_delete,
- can_moderate,
- can_read,
- can_write,
- get_content_snippet,
- is_locked,
-)
-
-from ..base import TemplateTestCase, wiki_override_settings
+from wiki.models import Article
+from wiki.models import ArticleRevision
+from wiki.templatetags.wiki_tags import can_delete
+from wiki.templatetags.wiki_tags import can_moderate
+from wiki.templatetags.wiki_tags import can_read
+from wiki.templatetags.wiki_tags import can_write
+from wiki.templatetags.wiki_tags import get_content_snippet
+from wiki.templatetags.wiki_tags import is_locked
+
+from ..base import TemplateTestCase
+from ..base import wiki_override_settings
User = get_user_model()
M tests/core/test_template_tags.py => tests/core/test_template_tags.py +7 -7
@@ 6,13 6,13 @@ from django.contrib.contenttypes.models import ContentType
from django.http import HttpRequest
from wiki.conf import settings
from wiki.forms import CreateRootForm
-from wiki.models import Article, ArticleForObject, ArticleRevision
-from wiki.templatetags.wiki_tags import (
- article_for_object,
- login_url,
- wiki_form,
- wiki_render,
-)
+from wiki.models import Article
+from wiki.models import ArticleForObject
+from wiki.models import ArticleRevision
+from wiki.templatetags.wiki_tags import article_for_object
+from wiki.templatetags.wiki_tags import login_url
+from wiki.templatetags.wiki_tags import wiki_form
+from wiki.templatetags.wiki_tags import wiki_render
from ..base import TemplateTestCase
M tests/core/test_urls.py => tests/core/test_urls.py +6 -3
@@ 1,8 1,11 @@
from django.contrib.sites.models import Site
from django.test.testcases import TestCase
-from django.urls import include, re_path
-from wiki.models import Article, URLPath
-from wiki.urls import WikiURLPatterns, get_pattern as get_wiki_pattern
+from django.urls import include
+from django.urls import re_path
+from wiki.models import Article
+from wiki.models import URLPath
+from wiki.urls import get_pattern as get_wiki_pattern
+from wiki.urls import WikiURLPatterns
from ..base import wiki_override_settings
M tests/core/test_views.py => tests/core/test_views.py +21 -22
@@ 7,19 7,20 @@ from django.test import override_settings
from django.utils import translation
from django.utils.html import escape
from django_functest import FuncBaseMixin
-from tests.testdata.models import CustomGroup
from wiki import models
-from wiki.forms import PermissionsForm, validate_slug_numbers
-from wiki.models import ArticleRevision, URLPath, reverse
-
-from ..base import (
- SUPERUSER1_USERNAME,
- ArticleWebTestUtils,
- DjangoClientTestBase,
- RequireRootArticleMixin,
- SeleniumBase,
- WebTestBase,
-)
+from wiki.forms import PermissionsForm
+from wiki.forms import validate_slug_numbers
+from wiki.models import ArticleRevision
+from wiki.models import reverse
+from wiki.models import URLPath
+
+from ..base import ArticleWebTestUtils
+from ..base import DjangoClientTestBase
+from ..base import RequireRootArticleMixin
+from ..base import SeleniumBase
+from ..base import SUPERUSER1_USERNAME
+from ..base import WebTestBase
+from tests.testdata.models import CustomGroup
class RootArticleViewTestsBase(FuncBaseMixin):
@@ 33,9 34,7 @@ class RootArticleViewTestsBase(FuncBaseMixin):
"""
self.get_url("wiki:root")
self.assertUrlsEqual(resolve_url("wiki:root_create"))
- self.fill(
- {"#id_content": "test heading h1\n====\n", "#id_title": "Wiki Test",}
- )
+ self.fill({"#id_content": "test heading h1\n====\n", "#id_title": "Wiki Test"})
self.submit('button[name="save_changes"]')
self.assertUrlsEqual("/")
self.assertTextPresent("test heading h1")
@@ 629,7 628,7 @@ class SourceViewTests(
):
def test_template_used(self):
response = self.client.get(
- reverse("wiki:source", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:source", kwargs={"article_id": self.root_article.pk})
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, template_name="wiki/source.html")
@@ 638,13 637,13 @@ class SourceViewTests(
# everybody can see the source of an article
self.client.logout()
response = self.client.get(
- reverse("wiki:source", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:source", kwargs={"article_id": self.root_article.pk})
)
self.assertEqual(response.status_code, 200)
def test_content(self):
response = self.client.get(
- reverse("wiki:source", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:source", kwargs={"article_id": self.root_article.pk})
)
self.assertIn("Source of ", str(response.content))
self.assertEqual(response.context["selected_tab"], "source")
@@ 655,13 654,13 @@ class HistoryViewTests(
):
def test_can_read_permission(self):
response = self.client.get(
- reverse("wiki:history", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:history", kwargs={"article_id": self.root_article.pk})
)
self.assertEqual(response.status_code, 200)
def test_content(self):
response = self.client.get(
- reverse("wiki:history", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:history", kwargs={"article_id": self.root_article.pk})
)
self.assertContains(response, "History:")
self.assertEqual(response.context["selected_tab"], "history")
@@ 700,7 699,7 @@ class SettingsViewTests(
group = CustomGroup.objects.create()
response = self.client.post(
resolve_url("wiki:settings", article_id=self.root_article.pk) + "?f=form0",
- {"group": group.pk, "owner_username": SUPERUSER1_USERNAME,},
+ {"group": group.pk, "owner_username": SUPERUSER1_USERNAME},
follow=True,
)
self.root_article.refresh_from_db()
@@ 766,6 765,6 @@ class SettingsViewTests(
def test_content(self):
response = self.client.get(
- reverse("wiki:settings", kwargs={"article_id": self.root_article.pk,})
+ reverse("wiki:settings", kwargs={"article_id": self.root_article.pk})
)
self.assertEqual(response.context["selected_tab"], "settings")
M tests/plugins/attachments/test_commands.py => tests/plugins/attachments/test_commands.py +2 -1
@@ 1,10 1,11 @@
import os
import tempfile
-from tests.core.test_commands import TestManagementCommands
from wiki.models import URLPath
from wiki.plugins.attachments import models
+from tests.core.test_commands import TestManagementCommands
+
class TestAttachmentManagementCommands(TestManagementCommands):
"""
M tests/plugins/attachments/test_models.py => tests/plugins/attachments/test_models.py +5 -2
@@ 1,5 1,8 @@
-from tests.base import RequireRootArticleMixin, TestBase
-from wiki.plugins.attachments.models import Attachment, AttachmentRevision
+from wiki.plugins.attachments.models import Attachment
+from wiki.plugins.attachments.models import AttachmentRevision
+
+from tests.base import RequireRootArticleMixin
+from tests.base import TestBase
class AttachmentRevisionTests(RequireRootArticleMixin, TestBase):
M tests/plugins/attachments/test_views.py => tests/plugins/attachments/test_views.py +13 -11
@@ 4,7 4,9 @@ from django.core.files.uploadedfile import InMemoryUploadedFile
from django.urls import reverse
from wiki.models import URLPath
-from ...base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin
+from ...base import ArticleWebTestUtils
+from ...base import DjangoClientTestBase
+from ...base import RequireRootArticleMixin
class AttachmentTests(
@@ 39,7 41,7 @@ class AttachmentTests(
filestream = self._createTxtFilestream(self.test_data)
response = self.client.post(
url,
- {"description": self.test_description, "file": filestream, "save": "1",},
+ {"description": self.test_description, "file": filestream, "save": "1"},
)
self.assertRedirects(response, url)
@@ 68,7 70,7 @@ class AttachmentTests(
data = "This is a plain text file"
filestream = self._createTxtFilestream(data)
self.client.post(
- url, {"description": "My file", "file": filestream, "save": "1",}
+ url, {"description": "My file", "file": filestream, "save": "1"}
)
attachment = self.article.shared_plugins_set.all()[0].attachment
@@ 85,7 87,7 @@ class AttachmentTests(
replacement_data = data + " And this is my edit"
replacement_filestream = self._createTxtFilestream(replacement_data)
self.client.post(
- url, {"description": "Replacement upload", "file": replacement_filestream,}
+ url, {"description": "Replacement upload", "file": replacement_filestream}
)
attachment = self.article.shared_plugins_set.all()[0].attachment
# Revision count should be two
@@ 140,28 142,28 @@ class AttachmentTests(
def test_render(self):
output = self.get_article("[attachment:1]")
expected = (
- '<span class="attachment"><a href=".*attachments/download/1/"'
- ' title="Click to download test\.txt">\s*test\.txt\s*</a>'
+ r'<span class="attachment"><a href=".*attachments/download/1/"'
+ r' title="Click to download test\.txt">\s*test\.txt\s*</a>'
)
self.assertRegexpMatches(output, expected)
def test_render_missing(self):
output = self.get_article("[attachment:2]")
- expected = '<span class="attachment attachment-deleted">\s*Attachment with ID #2 is deleted.\s*</span>'
+ expected = r'<span class="attachment attachment-deleted">\s*Attachment with ID #2 is deleted.\s*</span>'
self.assertRegexpMatches(output, expected)
def test_render_title(self):
output = self.get_article('[attachment:1 title:"Test title"]')
expected = (
- '<span class="attachment"><a href=".*attachments/download/1/"'
- ' title="Click to download test\.txt">\s*Test title\s*</a>'
+ r'<span class="attachment"><a href=".*attachments/download/1/"'
+ r' title="Click to download test\.txt">\s*Test title\s*</a>'
)
self.assertRegexpMatches(output, expected)
def test_render_title_size(self):
output = self.get_article('[attachment:1 title:"Test title 2" size]')
expected = (
- '<span class="attachment"><a href=".*attachments/download/1/"'
- ' title="Click to download test\.txt">\s*Test title 2 \[25[^b]bytes\]\s*</a>'
+ r'<span class="attachment"><a href=".*attachments/download/1/"'
+ r' title="Click to download test\.txt">\s*Test title 2 \[25[^b]bytes\]\s*</a>'
)
self.assertRegexpMatches(output, expected)
M tests/plugins/editsection/test_editsection.py => tests/plugins/editsection/test_editsection.py +3 -1
@@ 2,7 2,9 @@ from django.urls import reverse
from django_functest import FuncBaseMixin
from wiki.models import URLPath
-from ...base import DjangoClientTestBase, RequireRootArticleMixin, WebTestBase
+from ...base import DjangoClientTestBase
+from ...base import RequireRootArticleMixin
+from ...base import WebTestBase
TEST_CONTENT = (
"Title 1\n"
M tests/plugins/globalhistory/test_globalhistory.py => tests/plugins/globalhistory/test_globalhistory.py +3 -1
@@ 2,7 2,9 @@ from django.urls import reverse
from django.utils import translation
from wiki.models import URLPath
-from ...base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin
+from ...base import ArticleWebTestUtils
+from ...base import DjangoClientTestBase
+from ...base import RequireRootArticleMixin
class GlobalhistoryTests(
M tests/plugins/images/test_markdown.py => tests/plugins/images/test_markdown.py +3 -1
@@ 2,10 2,12 @@ import base64
from io import BytesIO
from django.core.files.uploadedfile import InMemoryUploadedFile
-from tests.base import RequireRootArticleMixin, TestBase
from wiki.core import markdown
from wiki.plugins.images import models
+from tests.base import RequireRootArticleMixin
+from tests.base import TestBase
+
class ImageMarkdownTests(RequireRootArticleMixin, TestBase):
def setUp(self):
M tests/plugins/images/test_views.py => tests/plugins/images/test_views.py +13 -15
@@ 10,12 10,10 @@ from wiki.models import URLPath
from wiki.plugins.images import models
from wiki.plugins.images.wiki_plugin import ImagePlugin
-from ...base import (
- ArticleWebTestUtils,
- DjangoClientTestBase,
- RequireRootArticleMixin,
- wiki_override_settings,
-)
+from ...base import ArticleWebTestUtils
+from ...base import DjangoClientTestBase
+from ...base import RequireRootArticleMixin
+from ...base import wiki_override_settings
class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):
@@ 106,10 104,10 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB
output = self.get_article("[image:1]", True)
image_rev = models.Image.objects.get().current_revision.imagerevision
expected = (
- '<figure class="thumbnail">'
- '<a href="' + image_rev.image.name + '">'
- '<img alt="test\.gif" src="cache/.*\.jpg">'
- '</a><figcaption class="caption"></figcaption></figure>'
+ r'<figure class="thumbnail">'
+ r'<a href="' + image_rev.image.name + '">'
+ r'<img alt="test\.gif" src="cache/.*\.jpg">'
+ r'</a><figcaption class="caption"></figcaption></figure>'
)
self.assertRegexpMatches(output, expected)
@@ 117,10 115,10 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB
output = self.get_article("[image:1 align:right size:large]", True)
image_rev = models.Image.objects.get().current_revision.imagerevision
expected = (
- '<figure class="thumbnail float-right">'
- '<a href="' + image_rev.image.name + '">'
- '<img alt="test\.gif" src="cache/.*\.jpg"></a>'
- '<figcaption class="caption"></figcaption></figure>'
+ r'<figure class="thumbnail float-right">'
+ r'<a href="' + image_rev.image.name + '">'
+ r'<img alt="test\.gif" src="cache/.*\.jpg"></a>'
+ r'<figcaption class="caption"></figcaption></figure>'
)
self.assertRegexpMatches(output, expected)
@@ 279,7 277,7 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB
image = models.Image.objects.get()
url = reverse(
"wiki:images_add_revision",
- kwargs={"article_id": self.root_article, "image_id": image.pk, "path": "",},
+ kwargs={"article_id": self.root_article, "image_id": image.pk, "path": ""},
)
response = self.client.post(url, data={"image": self.generate_photo_file()})
self.assertRedirects(response, "{}?next={}".format(reverse("wiki:login"), url))
M tests/plugins/links/test_urlize.py => tests/plugins/links/test_urlize.py +2 -1
@@ 2,7 2,8 @@ import html
import markdown
import pytest
-from wiki.plugins.links.mdx.urlize import UrlizeExtension, makeExtension
+from wiki.plugins.links.mdx.urlize import makeExtension
+from wiki.plugins.links.mdx.urlize import UrlizeExtension
# Template accepts two strings - href value and link text value.
EXPECTED_LINK_TEMPLATE = (
M tests/plugins/macros/test_links.py => tests/plugins/macros/test_links.py +3 -1
@@ 1,6 1,8 @@
-from tests.base import RequireRootArticleMixin, TestBase
from wiki.core import markdown
+from tests.base import RequireRootArticleMixin
+from tests.base import TestBase
+
class WikiLinksTests(RequireRootArticleMixin, TestBase):
def test_wikilink(self):
M tests/plugins/macros/test_macro.py => tests/plugins/macros/test_macro.py +3 -1
@@ 1,6 1,8 @@
-from tests.base import RequireRootArticleMixin, TestBase
from wiki.core import markdown
+from tests.base import RequireRootArticleMixin
+from tests.base import TestBase
+
class MacroTests(RequireRootArticleMixin, TestBase):
def test_article_list(self):
M tests/plugins/notifications/test_forms.py => tests/plugins/notifications/test_forms.py +2 -3
@@ 1,10 1,9 @@
from django.test import TestCase
-from django_nyt.forms import SettingsForm
+from wiki.plugins.notifications.forms import SettingsFormSet
from tests.base import RequireSuperuserMixin
-from wiki.plugins.notifications.forms import SettingsFormSet
class SettingsFormTests(RequireSuperuserMixin, TestCase):
def test_formset(self):
- formset = SettingsFormSet(user=self.superuser1)
+ SettingsFormSet(user=self.superuser1)
M tests/plugins/notifications/test_views.py => tests/plugins/notifications/test_views.py +4 -5
@@ 1,10 1,9 @@
from django.shortcuts import resolve_url
from django_nyt.models import Settings
-from tests.base import (
- ArticleWebTestUtils,
- DjangoClientTestBase,
- RequireRootArticleMixin,
-)
+
+from tests.base import ArticleWebTestUtils
+from tests.base import DjangoClientTestBase
+from tests.base import RequireRootArticleMixin
class NotificationSettingsTests(
M tests/plugins/redlinks/test_redlinks.py => tests/plugins/redlinks/test_redlinks.py +3 -1
@@ 1,7 1,9 @@
-from tests.base import RequireRootArticleMixin, TestBase
from wiki.core import markdown
from wiki.models import URLPath
+from tests.base import RequireRootArticleMixin
+from tests.base import TestBase
+
class RedlinksTests(RequireRootArticleMixin, TestBase):
def setUp(self):
M tests/settings.py => tests/settings.py +1 -1
@@ 6,7 6,7 @@ TESTS_DATA_ROOT = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(TESTS_DATA_ROOT, "media")
-DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3",}}
+DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}}
DEBUG = True
AUTH_USER_MODEL = "testdata.CustomUser"
M tests/testdata/migrations/0001_initial.py => tests/testdata/migrations/0001_initial.py +2 -2
@@ 1,9 1,9 @@
# Generated by Django 2.2.1 on 2019-07-03 19:03
-
import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
M tests/testdata/urls.py => tests/testdata/urls.py +3 -2
@@ 1,7 1,8 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
-from django.urls import include, re_path
+from django.urls import include
+from django.urls import re_path
urlpatterns = [
re_path(r"^admin/doc/", include("django.contrib.admindocs.urls")),
@@ 14,7 15,7 @@ if settings.DEBUG:
re_path(
r"^media/(?P<path>.*)$",
"django.views.static.serve",
- {"document_root": settings.MEDIA_ROOT,},
+ {"document_root": settings.MEDIA_ROOT},
),
]
M tox.ini => tox.ini +5 -2
@@ 5,12 5,13 @@ envlist = {py35,py36,py37}-django{21,22},{py36,py37,py38}-django{30},lint
[travis]
python =
3.5: py35
- 3.6: py36
+ 3.6: py36, lint
3.7: py37
3.8: py38
[travis:env]
DJANGO =
+ 2.1: django21
2.2: django22
3.0: django30
LINT =
@@ 44,8 45,10 @@ basepython =
py38: python3.8
[testenv:lint]
-basepython = python3
+basepython: python3
deps = .[testlint]
commands =
flake8 src/wiki
flake8 tests/
+ pre-commit install -f --install-hooks
+ pre-commit run --all-files --show-diff-on-failure