Skip to content

Commit

Permalink
DOC: Creating a coverage report (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Sep 3, 2022
1 parent b4b8f2d commit 3ec834d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
23 changes: 23 additions & 0 deletions 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.
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -60,6 +60,7 @@ You can contribute to `PyPDF2 on Github <https://github.com/py-pdf/PyPDF2>`_.
dev/pdf-format
dev/cmaps
dev/deprecations
dev/testing

.. toctree::
:caption: About PyPDF2
Expand Down
9 changes: 7 additions & 2 deletions 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

0 comments on commit 3ec834d

Please sign in to comment.