From 7823812f2d38a89064c1fa57344930c311898023 Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Wed, 3 Sep 2014 16:31:09 +0200 Subject: [PATCH] Add coverage --- .coveragerc | 9 +++++++++ .gitignore | 3 +++ indico/cli/server.py | 7 +++++-- pytest.ini | 4 ++-- requirements.txt | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000000..7be5c505431 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +[run] +branch = true +source = indico +include = indico/modules/rb/models/*.py + +[report] +exclude_lines = + pragma: no cover + def __repr__ diff --git a/.gitignore b/.gitignore index e7603198594..1a7435e22e2 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ node_modules .noseids indico/tests/report/*.txt test.txt +.coverage +coverage.xml +htmlcov/ diff --git a/indico/cli/server.py b/indico/cli/server.py index 2b94edbdf0c..309ebfc5db7 100644 --- a/indico/cli/server.py +++ b/indico/cli/server.py @@ -28,7 +28,7 @@ from flask_script import Command, Option from werkzeug.debug import DebuggedApplication from werkzeug.exceptions import NotFound -from werkzeug.wsgi import DispatcherMiddleware +from werkzeug.wsgi import DispatcherMiddleware, SharedDataMiddleware from indico.core.config import Config from indico.core.logger import Logger @@ -331,7 +331,10 @@ def start_web_server(app, host='localhost', port=0, with_ssl=False, keep_base_ur evalex_whitelist = True console.info(' * Using BaseURL {0}'.format(base_url)) - app = make_indico_dispatcher(app) + app.wsgi_app = make_indico_dispatcher(app.wsgi_app) + app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { + '/htmlcov': os.path.join(app.root_path, '..', 'htmlcov') + }, cache=False) server = WerkzeugServer(app, host, used_port, reload_on_change=reload_on_change, evalex_whitelist=evalex_whitelist, enable_ssl=with_ssl, ssl_cert=ssl_cert, ssl_key=ssl_key) signal.signal(signal.SIGINT, _sigint) diff --git a/pytest.ini b/pytest.ini index f685fc706c7..a21dafbaa41 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ [pytest] ; exclude unrelated folders and all old tests norecursedirs = .* .git indico/tests indico/modules/rb/tests test MaKaC doc etc ext_modules migrations -; more verbose summary (include skip/fail/error/warning), fixtures -addopts = -rsfEw +; more verbose summary (include skip/fail/error/warning), coverage +addopts = -rsfEw --cov indico --cov-report html --no-cov-on-fail ; only check for tests in suffixed files python_files = *_test.py diff --git a/requirements.txt b/requirements.txt index d53dc01de08..8a7ebdd85a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,8 +16,11 @@ py==1.4.23 pyPdf==1.13 pyatom==1.2 pycountry==1.2 +cov-core==1.14.0 +coverage==3.7.1 pytest==2.6.1 pytest-capturelog==0.7 +pytest-cov==1.8.0 python-dateutil==1.5 pytz==2014.4 reportlab==2.5