Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 29, 2022
1 parent c73fa32 commit af6f878
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
26 changes: 22 additions & 4 deletions app_helper/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.http import SimpleCookie
from django.test import RequestFactory, TestCase, TransactionTestCase
from django.utils.functional import SimpleLazyObject
from six import StringIO
from io import StringIO

from .utils import UserLoginContext, create_user, get_user_model, reload_urls, temp_dir

Expand Down Expand Up @@ -135,7 +135,13 @@ def request(
"""
request = getattr(RequestFactory(), method)(path, data=data, secure=secure)
return self._prepare_request(
request, page, user, lang, use_middlewares, secure=secure, use_toolbar=use_toolbar,
request,
page,
user,
lang,
use_middlewares,
secure=secure,
use_toolbar=use_toolbar,
)


Expand Down Expand Up @@ -193,7 +199,11 @@ def _setup_users(cls):
is_superuser=False,
)
cls.user_normal = create_user(
cls._user_user_username, cls._user_user_email, cls._user_user_password, is_staff=False, is_superuser=False,
cls._user_user_username,
cls._user_user_email,
cls._user_user_password,
is_staff=False,
is_superuser=False,
)

@classmethod
Expand Down Expand Up @@ -554,7 +564,15 @@ def get_request(self, page, lang, user=None, path=None, use_middlewares=False, s
)

def post_request(
self, page, lang, data, user=None, path=None, use_middlewares=False, secure=False, use_toolbar=False,
self,
page,
lang,
data,
user=None,
path=None,
use_middlewares=False,
secure=False,
use_toolbar=False,
):
"""
Create a POST request for the given page and language with CSRF disabled.
Expand Down
22 changes: 11 additions & 11 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@task
def clean(c):
""" Remove artifacts and binary files. """
"""Remove artifacts and binary files."""
c.run("python setup.py clean --all")
patterns = ["build", "dist"]
patterns.extend(glob("*.egg*"))
Expand All @@ -25,19 +25,19 @@ def clean(c):

@task
def lint(c):
""" Run linting tox environments. """
"""Run linting tox environments."""
c.run("tox -epep8,isort,black,pypi-description")


@task # NOQA
def format(c): # NOQA
""" Run code formatting tasks. """
"""Run code formatting tasks."""
c.run("tox -eblacken,isort_format")


@task
def towncrier_check(c): # NOQA
""" Check towncrier files. """
"""Check towncrier files."""
output = io.StringIO()
c.run("git branch --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
Expand Down Expand Up @@ -90,47 +90,47 @@ def towncrier_check(c): # NOQA

@task
def test(c):
""" Run test in local environment. """
"""Run test in local environment."""
c.run("python setup.py test")


@task
def test_all(c):
""" Run all tox environments. """
"""Run all tox environments."""
c.run("tox")


@task
def coverage(c):
""" Run test with coverage in local environment. """
"""Run test with coverage in local environment."""
c.run("coverage erase")
c.run("run setup.py test")
c.run("report -m")


@task
def tag_release(c, level):
""" Tag release version. """
"""Tag release version."""
c.run("bumpversion --list %s --no-tag" % level)


@task
def tag_dev(c, level="patch"):
""" Tag development version. """
"""Tag development version."""
c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level)


@task(pre=[clean])
def docbuild(c):
""" Build documentation. """
"""Build documentation."""
os.chdir("docs")
build_dir = os.environ.get("BUILD_DIR", "_build/html")
c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir)


@task(docbuild)
def docserve(c):
""" Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """
"""Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000)."""
from livereload import Server

server = Server()
Expand Down
7 changes: 6 additions & 1 deletion tests/test_utils/example1/tests/test_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ def test_requests(self):
self.assertEqual(request.META["REQUEST_METHOD"], "POST")
self.assertEqual(request.POST.get("payload"), "1")

request = self.get_page_request(pages[1], lang="en", user=self.user_staff, edit=True,)
request = self.get_page_request(
pages[1],
lang="en",
user=self.user_staff,
edit=True,
)
self.assertEqual(request.path, "/en/second-page/")
self.assertTrue(request.toolbar)
self.assertEqual(request.META["REQUEST_METHOD"], "GET")
Expand Down

0 comments on commit af6f878

Please sign in to comment.