Skip to content

Commit

Permalink
Merge pull request uisautomation#13 from rjw57/flake8
Browse files Browse the repository at this point in the history
Add Flake8 support for tox test runner
  • Loading branch information
rjw57 committed Dec 22, 2017
2 parents 0c9194f + f7d29fd commit 063f87f
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
10 changes: 3 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Editorconfig file for cross-platform configuration of editors.
root=true

[*.ini]
indent_style=space
indent_size=4

[*.{yml,yaml}]
indent_style=space
indent_size=2
[*.py]
max_line_length=99

[*.rst]
indent_style=space
Expand Down
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length=99
24 changes: 12 additions & 12 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Streaming Media Service Webapp documentation build configuration file, created by
# sphinx-quickstart on Fri Dec 8 11:20:11 2017.
# Streaming Media Service Webapp documentation build configuration file,
# created by sphinx-quickstart on Fri Dec 8 11:20:11 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
# This file is execfile()d with the current directory set to its containing
# dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# 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
Expand Down Expand Up @@ -139,7 +139,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'StreamingMediaServiceWebapp.tex', 'Streaming Media Service Webapp Documentation',
(master_doc, 'StreamingMediaServiceWebapp.tex',
'Streaming Media Service Webapp Documentation',
'University of Cambridge Information Services', 'manual'),
]

Expand All @@ -149,7 +150,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'streamingmediaservicewebapp', 'Streaming Media Service Webapp Documentation',
(master_doc, 'streamingmediaservicewebapp',
'Streaming Media Service Webapp Documentation',
[author], 1)
]

Expand All @@ -160,10 +162,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'StreamingMediaServiceWebapp', 'Streaming Media Service Webapp Documentation',
(master_doc, 'StreamingMediaServiceWebapp',
'Streaming Media Service Webapp Documentation',
author, 'StreamingMediaServiceWebapp', 'One line description of project.',
'Miscellaneous'),
]



16 changes: 16 additions & 0 deletions doc/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ pull request. Some items to note:
using the PostgreSQL database and *not* sqlite. If you only run unit tests
locally with sqlite then it is possible that some tests may fail.

Code-style
``````````

The ``tox`` test runner will automatically check the code with `flake8
<http://flake8.pycqa.org/>`_ to ensure PEP8 compliance. Sometimes, however,
rules are made to be broken and so you may find yourself needing to use the
`noqa in-line comment
<http://flake8.pycqa.org/en/latest/user/violations.html#in-line-ignoring-errors>`_
mechanism to silence individual errors.

To run the flake8 tests manually, specify the tox environment:

.. code:: bash
$ tox -e flake8
Documentation
`````````````

Expand Down
2 changes: 1 addition & 1 deletion smswebapp/settings_developer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Import settings from the base settings file
from .settings import *
from .settings import * # noqa: F401, F403

# Use Demo Raven server
UCAMWEBAUTH_LOGIN_URL = 'https://demo.raven.cam.ac.uk/auth/authenticate.html'
Expand Down
4 changes: 2 additions & 2 deletions smswebapp/settings_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"""
# Import settings from the base settings file
from .settings import *
from .settings import * # noqa: F401, F403


#: The default test runner is changed to one which captures stdout and stderr
#: when running tests.
TEST_RUNNER='smswebapp.test.runner.BufferedDiscoverRunner'
TEST_RUNNER = 'smswebapp.test.runner.BufferedDiscoverRunner'
4 changes: 2 additions & 2 deletions smswebapp/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self, stream=None, descriptions=True, verbosity=1,
class BufferedDiscoverRunner(django.test.runner.DiscoverRunner):
"""
A sub-class of :py:class:`django.test.runner.DiscoverRunner` which has
exactly the same behaviour except that the :py:attr:`.test_runner` attribute
is set to :py:class:`.BufferedTextTestRunner`.
exactly the same behaviour except that the :py:attr:`.test_runner`
attribute is set to :py:class:`.BufferedTextTestRunner`.
The upshot of this is that output to stdout and stderror is captured and
only reported on test failure.
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=py36,doc
envlist=py36,doc,flake8

[testenv]
# Additional dependencies
Expand All @@ -24,3 +24,10 @@ commands=
basepython=python3.6
deps=-rdoc/requirements.txt
commands=sphinx-build -a -v -b html doc/ {toxinidir}/build/doc/

[testenv:flake8]
basepython=python3.6
deps=flake8
commands=
flake8 --version
flake8 smswebapp doc

0 comments on commit 063f87f

Please sign in to comment.