From be86e2e1bd2d21955e9d6e4172eae01b25a63abb Mon Sep 17 00:00:00 2001 From: Chris B Date: Thu, 19 Dec 2019 11:58:35 +0000 Subject: [PATCH] Add coverage to travis and fix coverage collection (#38) Fixes #26 Using pytest-cov (a pytest plugin) to measure the coverage of nbsmoke - which is itself a pytest plugin - is a little bit tricky. So just use coverage without the pytest-cov plugin. --- .travis.yml | 5 +++++ README.rst | 3 +++ tox.ini | 14 +++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a6a627..7b8e81d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,11 @@ jobs: # like a python-using developer env: TOX_ENV=dev + - <<: *default + # measuring coverage of a pytest plugin using pytest-cov is slightly awkward, + # so we have a separate step for it + env: TOX_ENV=coverage + - <<: *default stage: pip_package install: true diff --git a/README.rst b/README.rst index 71ae2a9..67ca035 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,9 @@ :target: https://ci.appveyor.com/project/pyviz/nbsmoke/branch/master :alt: See Build Status on AppVeyor +.. image:: https://coveralls.io/repos/github/pyviz-dev/nbsmoke/badge.svg?branch=master + :target: https://coveralls.io/github/pyviz-dev/nbsmoke?branch=master + :alt: See coverage stats on Coveralls ======= nbsmoke diff --git a/tox.ini b/tox.ini index e22d807..d562384 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,24 @@ [tox] envlist = py27,py36,py37,py38,pypy,flake8,dev -# TODO: shouldn't be 'all' in every case. +# TODO: shouldn't be extras=all in every case. [testenv] commands = py.test -v {posargs:tests} extras = all +[testenv:coverage] +setdevelop = True +passenv = TRAVIS TRAVIS_* +# don't use pytest-cov as nbsmoke is itself a pytest plugin, so things +# get confusing (e.g. nbsmoke gets imported before coverage collection +# starts, so all the module-level code is missed) +commands = coverage run --source=nbsmoke -m pytest + coverage report -m + coveralls +extras = all +deps = coveralls + [testenv:flake8] skip_install = true deps = flake8