diff --git a/.coveragerc b/.coveragerc index c1b7a4327f8d655d75b7cea1e93cf4d1b19892b5..d68648e8c096f0300e16d601dbe217ddb7a38a72 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,5 @@ [run] -include = gimmecert/* \ No newline at end of file +include = gimmecert/* + +[report] +fail_under = 100 \ No newline at end of file diff --git a/docs/development.rst b/docs/development.rst index 28ca2a156d90f9b38664e09a5e62648ea2c75ae7..ef4d2455c2d08b18bee1d8dd6eeca9766611b62b 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -67,9 +67,6 @@ Testing Project includes both unit tests (within ``tests/`` directory) , and functional tests (within ``functional_tests/`` directory). -Running the tests will also generate coverage report in HTML format, -stored within directory ``coverage/``. - Tests can be run in a number of different ways, depending on what you want to test and how. @@ -83,21 +80,47 @@ repository root:: pytest +Tests can be also run with coverage checks. By default coverage is +configured to report to standard output. Report will only list files +which lack coverage. For each file a percentage will be shown, as well +as line numbers that were not covered by tests. To include coverage +checks, run tests with:: + + pytest --cov + +.. warning:: + Gimmecert project has 100% coverage requirement. Anything below + will trigger failures when coverage checks are run. + +Should you desire to generate coverage report in HTML format, run +(coverage report will be put into directory ``coverage/``):: + + pytest --cov --cov-report=html:coverage/ + Functional tests must be run explicitly (since they tend to take more time), with:: pytest functional_tests/ -Linting checks are performed as part of testing. Linting checks can -easily be run with command:: +In addition to proper linting, implemented code should be pruned of +unused imports and variables. Linting should be conformant to PEP8, +with the exception of line length, which is allowed to be up to 160 +characters. Linting and code sanity checks are not executed +automatically, but can easily be run with:: flake8 +Documentation should be buildable at all times. Documentation build +can be triggered with a simple:: + + cd docs/ + make html + Tests can also be run using `tox `_: .. note:: - When running tests via ``tox``, functional tests are included as - well. + When running tests via ``tox``, functional tests and coverage + checks are included as well. :: diff --git a/pytest.ini b/pytest.ini index aee70046d0190540df49774a2a0fc49b5f6a72cf..eed06c2e48efe6a7278ab7150d4cbcac261f3fb7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,3 @@ [pytest] -addopts = --flake8 --cov --cov-report=html:coverage \ No newline at end of file +addopts = --cov-report=term-missing:skip-covered +testpaths = tests/ \ No newline at end of file diff --git a/setup.py b/setup.py index 260b1ec9e1873949dde3d905fa3f015af21e4b4a..41019f205ed75e1e94e85e5434e0353ad21f9a1d 100755 --- a/setup.py +++ b/setup.py @@ -37,11 +37,10 @@ test_lint_requirements = [ 'flake8>=3.5,<3.6', ] -test_requirements = test_lint_requirements + [ +test_requirements = [ 'freezegun>=0.3,<0.4', 'pytest>=3.4,<3.5', 'pytest-cov>=2.5,<2.6', - 'pytest-flake8>=0.9,<0.10', 'tox>=2.9,<2.10', ] diff --git a/tox.ini b/tox.ini index 0541b6cc6c26a3a2150fc3a430807b3775694228..89b12037325e5f4ac238637ce0fa875c09f1ee43 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,13 @@ [tox] envlist = {py34,py35,py36},lint,doc - [testenv] whitelist_externals = make basepython = + doc: python3 + lint: python3 py34: python3.4 py35: python3.5 py36: python3.6 @@ -15,20 +16,25 @@ deps = .[test] commands = - pytest --basetemp={envtmpdir} - pytest --basetemp={envtmpdir} functional_tests/ + # Must specify cov-report explicitly, otherwise coverage starts + # going through the tests as well. + pytest --cov --cov-report=term-missing:skip-covered --basetemp={envtmpdir} tests/ functional_tests/ [testenv:lint] -basepython = python3 deps = .[testlint] commands = flake8 [testenv:doc] -basepython = python3 deps = .[doc] -changedir = {toxinidir}/docs/ +setenv = + # Override Sphinx build directory so we do not trample over user's + # build in source directory. + BUILDDIR={envtmpdir}/docs_build commands = - make html \ No newline at end of file + # Easier to run than changing directory with separate comand. -e + # will ensure the BUILDDIR gets picked-up and overrides the Makefile + # content. + make -C docs/ -e html