From 5cadd4a348b4d42e22ddb2bfad93f74a4f34cc59 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov Date: Wed, 8 Jun 2016 08:26:01 -0400 Subject: [PATCH] Added make target for test coverage, documented make commands --- .gitignore | 2 ++ CONTRIBUTING.rst | 25 ++++++++++++++++--------- Makefile | 5 +++++ test-requirements.txt | 2 ++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 9bf4f063..e754af19 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ _mailinglist .tox .cache/ .idea/ +.coverage +htmlcov diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ca7b4af2..f4d1ef9c 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -31,18 +31,12 @@ Submitting patches - Try to follow `PEP8 `_, but you may ignore the line-length-limit if following it would make the code uglier. - -Running the testsuite ---------------------- +Getting Started +=============== You probably want to set up a `virtualenv `_. -The minimal requirement for running the testsuite is ``py.test``. You can -install it with:: - - pip install pytest - Clone this repository:: git clone https://github.com/pallets/flask.git @@ -52,11 +46,21 @@ Install Flask as an editable package using the current source:: cd flask pip install --editable . +Running the testsuite +--------------------- + +The minimal requirement for running the testsuite is ``pytest``. You can +install it with:: + + pip install pytest + Then you can run the testsuite with:: py.test -With only py.test installed, a large part of the testsuite will get skipped +**Shortcut**: ``make test`` will ensure ``pytest`` is installed, and run it. + +With only pytest installed, a large part of the testsuite will get skipped though. Whether this is relevant depends on which part of Flask you're working on. Travis is set up to run the full testsuite when you submit your pull request anyways. @@ -69,6 +73,8 @@ of ``pytest``. You can install it with:: The ``tox`` command will then run all tests against multiple combinations Python versions and dependency versions. +**Shortcut**: ``make tox-test`` will ensure ``tox`` is installed, and run it. + Running test coverage --------------------- Generating a report of lines that do not have unit test coverage can indicate where @@ -87,3 +93,4 @@ Generate a HTML report can be done using this command:: Full docs on ``coverage.py`` are here: https://coverage.readthedocs.io +**Shortcut**: ``make cov`` will ensure ``pytest-cov`` is installed, run it, display the results, *and* save the HTML report. diff --git a/Makefile b/Makefile index 9bcdebc2..3fcb765d 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,13 @@ test: FLASK_DEBUG= py.test tests examples tox-test: + pip install -r test-requirements.txt -q tox +cov: + pip install -r test-requirements.txt -q + FLASK_DEBUG= py.test --cov-report term --cov-report html --cov=flask --cov=examples tests examples + audit: python setup.py audit diff --git a/test-requirements.txt b/test-requirements.txt index e079f8a6..8be82dd0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,3 @@ +tox pytest +pytest-cov