From 3ec834de9bf4cc6a9830aef9e8eb7131fa642cf0 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sat, 3 Sep 2022 16:54:39 +0200 Subject: [PATCH] DOC: Creating a coverage report (#1319) --- docs/dev/testing.md | 23 +++++++++++++++++++++++ docs/index.rst | 1 + tox.ini | 9 +++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 docs/dev/testing.md diff --git a/docs/dev/testing.md b/docs/dev/testing.md new file mode 100644 index 000000000..e3b11f2bf --- /dev/null +++ b/docs/dev/testing.md @@ -0,0 +1,23 @@ +# Testing + +PyPDF2 uses [`pytest`](https://docs.pytest.org/en/7.1.x/) for testing. + +## Creating a Coverage Report + +If you want to get a coverage report that considers the Python version specific +code, you can run [`tox`](https://tox.wiki/en/latest/). + +As a prerequisite, we recommend using [`pyenv`](https://github.com/pyenv/pyenv) +so that you can install the different Python versions: + +``` +pyenv install pypy3.8-7.3.7 +pyenv install 3.6.15 +pyenv install 3.7.12 +pyenv install 3.8.12 +pyenv install 3.9.10 +pyenv install 3.10.2 +``` + +Then you can execute `tox` which will create a coverage report in HTML form +in the end. The execution takes about 30 minutes. diff --git a/docs/index.rst b/docs/index.rst index 1d63c9102..6aba9b844 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -60,6 +60,7 @@ You can contribute to `PyPDF2 on Github `_. dev/pdf-format dev/cmaps dev/deprecations + dev/testing .. toctree:: :caption: About PyPDF2 diff --git a/tox.ini b/tox.ini index 44bab4970..7f4bf146f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,16 @@ [tox] envlist = - py{36,37,38,39,310,py,py3} + py{36,37,38,39,310,py3},cov [testenv] +setenv= + py{36,37,38,39,310,py3}: COVERAGE_FILE={envdir}/.coverage deps = pillow pytest pytest-cov pycryptodome -commands = pytest tests --cov --cov-report term-missing -vv {posargs} +commands = + py{36,37,38,39,310,py3}: pytest tests --cov --cov-report term-missing -vv --no-cov-on-fail {posargs} + cov: /usr/bin/env bash -c '{envpython} -m coverage combine {toxworkdir}/py*/.coverage' + cov: coverage html --fail-under=85