[Answered ]-Is Python 3.9.6 compatible with pytest 6.2.5?

1👍

First of all, yes, Python 3.9.6 is compatible with pytest 6.2.5, however, you appear to be missing a few dependencies. pytest is one of many different Python packages, and you appear to have installed that successfully, so you’re halfway there.

There are a few different coverage plugins that work with pytest, and those need to be installed separately. Here are the two most common coverage plugins for Python and pytest:

https://pypi.org/project/coverage/

https://pypi.org/project/pytest-cov/

The first one, coverage is installed with:

pip install coverage

The second one, pytest-cov is installed with:

pip install pytest-cov

Based on your run command, you appear to want to use pytest-cov. After you’ve installed that, you can verify that pytest has those new options by calling pytest --help:

> pytest --help

...
coverage reporting with distributed testing support:
  --cov=[SOURCE]        Path or package name to measure during execution (multi-allowed). Use --cov= to
                        not do any source filtering and record everything.
  --cov-reset           Reset cov sources accumulated in options so far.
  --cov-report=TYPE     Type of report to generate: term, term-missing, annotate, html, xml (multi-
                        allowed). term, term-missing may be followed by ":skip-covered". annotate, html
                        and xml may be followed by ":DEST" where DEST specifies the output location.
                        Use --cov-report= to not generate any output.
  --cov-config=PATH     Config file for coverage. Default: .coveragerc
  --no-cov-on-fail      Do not report coverage if test run fails. Default: False
  --no-cov              Disable coverage report completely (useful for debuggers). Default: False
  --cov-fail-under=MIN  Fail if the total coverage is less than MIN.
...

Alternatively, you might be able to get the same results you’re looking for using coverage:

coverage run -m pytest

coverage html

coverage report

And that will also give you a coverage report even if not using pytest-cov options.

Leave a comment