Fixes missing config settings around tox and flake8.
Adds toxenv 'fix' to automatically fix PEP8 issues. As we have disabled
so many PEP8 warnings, this currently fixes issues that may pass through
the toxenv 'lint'.
Fixes: https://tracker.ceph.com/issues/41379
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
$ pip install tox
$ pip install coverage
-To run the tests, run ``run_tox.sh`` in the dashboard directory (where
+To run the tests, run ``src/script/run_tox.sh`` in the dashboard directory (where
``tox.ini`` is located)::
## Run Python 2+3 tests+lint commands:
## Run Python 3 arbitrary command (e.g. 1 single test):
$ tox -e py3 tests/test_rgw_client.py::RgwClientTest::test_ssl_verify
+Python files can be automatically fixed and formatted according to PEP8
+standards by using ``run_tox.sh --tox-env fix`` or ``tox -e fix``.
+
We also collect coverage information from the backend code when you run tests. You can check the
coverage information provided by the tox output, or by running the following
command after tox has finished successfully::
-pylint
-flake8
-flake8-colors
+pylint==2.3.1; python_version >= '3'
+flake8==3.7.8; python_version >= '3'
+flake8-colors==0.1.6; python_version >= '3'
#TODO: Fix docstring issues: https://tracker.ceph.com/issues/41224
#flake8-docstrings
#flake8-import-order
#flake8-typing-imports; python_version >= '3'
#pep8-naming
-rstcheck
+rstcheck==3.3.1; python_version >= '3'
+autopep8; python_version >= '3'
envlist =
py{27,3},
lint,
+ fix,
check,
run,
skipsdist = true
[flake8]
max-line-length = 100
ignore = E123 E126 E226 E402 W503 E741 F812
-exclude = venv, frontend, .*
+exclude =
+ .tox,
+ .git,
+ __pycache__,
+ build,
+ dist,
+ *.egg-info,
+ .cache,
+ *.pyc,
+ .eggs,
+ venv,
+ frontend,
statistics = True
#TODO: Uncomment and refactor (https://tracker.ceph.com/issues/41221)
#max-complexity = 10
HACKING.rst
[testenv:lint]
-basepython = python3
+basepython=python3
deps =
-rrequirements-lint.txt
commands =
- rstcheck --report info --debug {posargs:{[rstlint]dirs}}
- flake8 {posargs}
- pylint {[pylint]addopts} {posargs:{[pylint]dirs}}
+ lint: flake8 {posargs}
+ lint: pylint {[pylint]addopts} {posargs:{[pylint]dirs}}
+ lint: rstcheck --report info --debug {posargs:{[rstlint]dirs}}
+
+
+[autopep8]
+addopts =
+ --max-line-length {[flake8]max-line-length}
+ --exclude "{[flake8]exclude}"
+ --in-place
+ --recursive
+# TODO: we should progressively increase the level of compliance with PEP8
+# --aggressive
+# --aggressive
+
+[testenv:fix]
+basepython=python3
+deps =
+ -rrequirements-lint.txt
+commands =
+ python --version
+ autopep8 {[autopep8]addopts} {posargs:.}
[testenv:check]