From 18b71780c03f9b84e49e5212889ca5b44749664e Mon Sep 17 00:00:00 2001 From: Holger Kohr Date: Wed, 13 Mar 2019 21:54:31 +0100 Subject: [PATCH] MAINT: move coverage config to setup.cfg (#1481) * MAINT: move coverage config to setup.cfg * TST: improve list of excludes from coverage * Exclude defs and such from coverage * Remove defs, clas and triple quotes from coverage excludes * Remove decorators, add entry points to coverage skip * Run coverage manually to improve reported coverage * Check if failing tests still make CI fail * Make failing tests fail CI again, remove pytest-pep8 and pytest-cov * Remove test failure --- .coveragerc | 56 ------------------------------------------- .travis.yml | 7 +++--- odl/util/testutils.py | 2 +- setup.cfg | 52 +++++++++++++++++++++++++++++++++++----- 4 files changed, 51 insertions(+), 66 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index e149b39fe39..00000000000 --- a/.coveragerc +++ /dev/null @@ -1,56 +0,0 @@ -# .coveragerc to control coverage.py -[run] -branch = False - -include = - odl/* - -omit = - */__init__.py - odl/diagnostics/* - odl/util/* - - # Omit until coveralls supports cuda. - odl/space/cu_ntuples.py - - # Omit until coveralls supports pywt. - odl/trafos/wavelet.py - - # Omit until coveralls supports astra. - odl/tomo/operators/xray_trafo.py - odl/tomo/backends/* - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about missing debug-only code: - if self\.debug - - # Printing-related functions - def __str__ - def __repr__ - def _repr - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - return NotImplemented - - # Skip imports and __all__ - import * - __all__ - - # Decorators - @property - - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == '__main__': - -ignore_errors = True - -[html] -directory = htmlcov diff --git a/.travis.yml b/.travis.yml index 30d3a7a4bb3..5440df0c86d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ install: - conda create -n testenv python=$TRAVIS_PYTHON_VERSION nomkl - source activate testenv # Install packages with pip if possible, it's way faster - - pip install "numpy==$NUMPY_VERSION" scipy future packaging scikit-image pywavelets pytest pytest-cov; + - pip install "numpy==$NUMPY_VERSION" scipy future packaging scikit-image pywavelets; # Building pyfftw wheels sometimes fails, using a conda-forge version instead; # To avoid a lower version of NumPy being installed over the pip one, we exclude all dependencies # (PyFFTW only depends on NumPy) @@ -72,8 +72,9 @@ script: # Also invoke the alternative way of running the unit tests. # Fail immediately after first failure to speed up the whole thing. - if [[ "$SKIP_TESTS" != "true" ]]; then - pytest --doctest-modules --cov --cov-report term-missing $TRAVIS_BUILD_DIR/odl || exit -1; - python -c "import odl; odl.test()" || exit -1; + pytest --doctest-modules $TRAVIS_BUILD_DIR/odl || exit -1; + echo "import odl; odl.test(['--doctest-modules'])" > $TRAVIS_BUILD_DIR/_run_tests.py; + coverage run $TRAVIS_BUILD_DIR/_run_tests.py; fi # Build the Sphinx doc (only for one specific build, master branch, no PR) # To avoid clogging the logs, we redirect stderr to /dev/null diff --git a/odl/util/testutils.py b/odl/util/testutils.py index 4e6f659df80..c71579a8e3e 100644 --- a/odl/util/testutils.py +++ b/odl/util/testutils.py @@ -675,7 +675,7 @@ def test(arguments=None): this_dir = os.path.dirname(__file__) odl_root = os.path.abspath(os.path.join(this_dir, os.pardir, os.pardir)) - args = ['-x', '{root}/odl'.format(root=odl_root)] + args = ['{root}/odl'.format(root=odl_root)] ignores = ['--ignore={}'.format(file) for file in collect_ignore] args.extend(ignores) diff --git a/setup.cfg b/setup.cfg index 7538f7c70e3..71bd7c5cad0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,6 +12,7 @@ url = https://github.com/odlgroup/odl download_url = https://github.com/odlgroup/odl/archive/master.zip platforms = any keywords = research, development, mathematics, prototyping, imaging, tomography +# See https://pypi.org/classifiers/ classifiers = Development Status :: 4 - Beta Intended Audience :: Developers @@ -44,8 +45,6 @@ install_requires = python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* tests_require = pytest >=3.0.3 - pytest-pep8 - pytest-cov coverage >=4.0 coveralls include_package_data = True @@ -61,14 +60,10 @@ tests = odl/test, odl/pytest.ini [options.extras_require] testing = pytest >=3.0.3 - pytest-pep8 - pytest-cov coverage >=4.0 coveralls all = pytest >=3.0.3 - pytest-pep8 - pytest-cov coverage >=4.0 coveralls matplotlib @@ -111,3 +106,48 @@ max-line-length = 79 exclude = .git __pycache__ + +[coverage:run] +branch = False +include = + odl/* +omit = + */__init__.py + odl/test/* + odl/diagnostics/* + odl/space/entry_points.py + odl/util/graphics.py + odl/util/npy_compat.py + odl/util/pytest_config.py + odl/util/testutils.py + + # Omit until we add ASTRA to our CI pipelines + odl/tomo/operators/ray_trafo.py + odl/tomo/backends/* + +[coverage:report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain if tests don't hit defensive assertion code: + assert False + raise AssertionError + raise NotImplementedError + return NotImplemented + + # Skip imports and __all__ + import * + __all__ + + # Don't complain if non-runnable code isn't run: + if 0: + if False: + if __name__ == '__main__': + +ignore_errors = True + +[coverage:html] +directory = htmlcov +