diff --git a/.appveyor.yml b/.appveyor.yml index b5c6654e..6ee159e9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,15 +1,36 @@ # NOTE: this file is auto-generated via ci/bootstrap.py (ci/templates/.appveyor.yml). version: '{branch}-{build}' build: off +image: + - Visual Studio 2015 + - Visual Studio 2019 environment: matrix: - TOXENV: check - - TOXENV: 'py27-pytest46-xdist27-coverage45,py27-pytest46-xdist27-coverage52' - - TOXENV: 'py35-pytest46-xdist27-coverage45,py35-pytest46-xdist27-coverage52' - - TOXENV: 'py36-pytest46-xdist27-coverage45,py36-pytest46-xdist27-coverage52,py36-pytest46-xdist33-coverage45,py36-pytest46-xdist33-coverage52,py36-pytest54-xdist33-coverage45,py36-pytest54-xdist33-coverage52,py36-pytest60-xdist200-coverage52' - - TOXENV: 'py37-pytest46-xdist27-coverage45,py37-pytest46-xdist27-coverage52,py37-pytest46-xdist33-coverage45,py37-pytest46-xdist33-coverage52,py37-pytest54-xdist33-coverage45,py37-pytest54-xdist33-coverage52,py37-pytest60-xdist200-coverage52' - - TOXENV: 'pypy-pytest46-xdist27-coverage45,pypy-pytest46-xdist27-coverage52' - + - TOXENV: 'py27-pytest46-xdist127-coverage55' + - TOXENV: 'py35-pytest46-xdist127-coverage55' + - TOXENV: 'py36-pytest46-xdist127-coverage55,py36-pytest46-xdist133-coverage55,py36-pytest54-xdist133-coverage55,py36-pytest62-xdist202-coverage55' + - TOXENV: 'py37-pytest46-xdist127-coverage55,py37-pytest46-xdist133-coverage55,py37-pytest54-xdist133-coverage55,py37-pytest62-xdist202-coverage55' + - TOXENV: 'py38-pytest46-xdist133-coverage55,py38-pytest54-xdist133-coverage55,py38-pytest62-xdist202-coverage55' + - TOXENV: 'py39-pytest62-xdist202-coverage55' + - TOXENV: 'pypy-pytest46-xdist127-coverage55' + - TOXENV: 'pypy3-pytest46-xdist127-coverage55,pypy3-pytest46-xdist133-coverage55,pypy3-pytest54-xdist133-coverage55,pypy3-pytest62-xdist202-coverage55' +matrix: + exclude: + - image: Visual Studio 2015 + TOXENV: 'py27-pytest46-xdist127-coverage55' + - image: Visual Studio 2019 + TOXENV: 'py36-pytest46-xdist127-coverage55,py36-pytest46-xdist133-coverage55,py36-pytest54-xdist133-coverage55,py36-pytest62-xdist202-coverage55' + - image: Visual Studio 2019 + TOXENV: 'py37-pytest46-xdist127-coverage55,py37-pytest46-xdist133-coverage55,py37-pytest54-xdist133-coverage55,py37-pytest62-xdist202-coverage55' + - image: Visual Studio 2019 + TOXENV: 'py38-pytest46-xdist133-coverage55,py38-pytest54-xdist133-coverage55,py38-pytest62-xdist202-coverage55' + - image: Visual Studio 2019 + TOXENV: 'py39-pytest62-xdist202-coverage55' + - image: Visual Studio 2019 + TOXENV: 'pypy-pytest46-xdist127-coverage55' + - image: Visual Studio 2019 + TOXENV: 'pypy3-pytest46-xdist127-coverage55,pypy3-pytest46-xdist133-coverage55,pypy3-pytest54-xdist133-coverage55,pypy3-pytest62-xdist202-coverage55' init: - ps: echo $env:TOXENV - ps: ls C:\Python* diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 30a7014b..7e15ff94 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.10.0 +current_version = 2.12.0 commit = True tag = True @@ -7,9 +7,13 @@ tag = True search = version='{current_version}' replace = version='{new_version}' -[bumpversion:file:README.rst] -search = v{current_version}. -replace = v{new_version}. +[bumpversion:file (badge):README.rst] +search = /v{current_version}.svg +replace = /v{new_version}.svg + +[bumpversion:file (link):README.rst] +search = /v{current_version}...master +replace = /v{new_version}...master [bumpversion:file:docs/conf.py] search = version = release = '{current_version}' diff --git a/.cookiecutterrc b/.cookiecutterrc index c477a6f5..9cad1178 100644 --- a/.cookiecutterrc +++ b/.cookiecutterrc @@ -1,9 +1,6 @@ # Generated by cookiepatcher, a small shim around cookiecutter (pip install cookiepatcher) -cookiecutter: - _extensions: - - jinja2_time.TimeExtension - _template: /home/ionel/open-source/cookiecutter-pylibrary +default_context: allow_tests_inside_package: no appveyor: yes c_extension_function: '-' @@ -23,7 +20,7 @@ cookiecutter: distribution_name: pytest-cov email: contact@ionelmc.ro full_name: Ionel Cristian Mărieș - landscape: no + legacy_python: yes license: MIT license linter: flake8 package_name: pytest_cov @@ -50,7 +47,7 @@ cookiecutter: test_runner: pytest travis: yes travis_osx: no - version: 2.10.0 + version: 2.10.1 website: http://blog.ionelmc.ro year_from: '2010' year_to: '2020' diff --git a/.editorconfig b/.editorconfig index a9c7977a..586c7367 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,10 +2,11 @@ root = true [*] +# Use Unix-style newlines for most files (except Windows files, see below). end_of_line = lf trim_trailing_whitespace = true -insert_final_newline = true indent_style = space +insert_final_newline = true indent_size = 4 charset = utf-8 @@ -14,3 +15,6 @@ end_of_line = crlf [*.{yml,yaml}] indent_size = 2 + +[*.tsv] +indent_style = tab diff --git a/.gitignore b/.gitignore index dfe58380..83a43fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -39,11 +39,14 @@ htmlcov # Translations *.mo -# Mr Developer +# Buildout .mr.developer.cfg + +# IDE project files .project .pydevproject .idea +.vscode *.iml *.komodoproject diff --git a/.travis.yml b/.travis.yml index 3c96aad9..a9cafa4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,69 +20,43 @@ jobs: - env: TOXENV=docs - stage: tests - env: TOXENV=py27-pytest46-xdist27-coverage45 + env: TOXENV=py27-pytest46-xdist127-coverage55 python: '2.7' - - env: TOXENV=py27-pytest46-xdist27-coverage52 - python: '2.7' - - env: TOXENV=py35-pytest46-xdist27-coverage45 - python: '3.5' - - env: TOXENV=py35-pytest46-xdist27-coverage52 + - env: TOXENV=py35-pytest46-xdist127-coverage55 python: '3.5' - - env: TOXENV=py36-pytest46-xdist27-coverage45 + - env: TOXENV=py36-pytest46-xdist127-coverage55 python: '3.6' - - env: TOXENV=py36-pytest46-xdist27-coverage52 - python: '3.6' - - env: TOXENV=py37-pytest46-xdist27-coverage45 - python: '3.7' - - env: TOXENV=py37-pytest46-xdist27-coverage52 + - env: TOXENV=py37-pytest46-xdist127-coverage55 python: '3.7' - - env: TOXENV=pypy-pytest46-xdist27-coverage45 + - env: TOXENV=pypy-pytest46-xdist127-coverage55 python: 'pypy' - - env: TOXENV=pypy-pytest46-xdist27-coverage52 - python: 'pypy' - - env: TOXENV=pypy3-pytest46-xdist27-coverage45 - python: 'pypy3' - - env: TOXENV=pypy3-pytest46-xdist27-coverage52 + - env: TOXENV=pypy3-pytest46-xdist127-coverage55 python: 'pypy3' - - env: TOXENV=py36-pytest46-xdist33-coverage45 - python: '3.6' - - env: TOXENV=py36-pytest46-xdist33-coverage52 + - env: TOXENV=py36-pytest46-xdist133-coverage55 python: '3.6' - - env: TOXENV=py36-pytest54-xdist33-coverage45 + - env: TOXENV=py36-pytest54-xdist133-coverage55 python: '3.6' - - env: TOXENV=py36-pytest54-xdist33-coverage52 - python: '3.6' - - env: TOXENV=py37-pytest46-xdist33-coverage45 - python: '3.7' - - env: TOXENV=py37-pytest46-xdist33-coverage52 + - env: TOXENV=py37-pytest46-xdist133-coverage55 python: '3.7' - - env: TOXENV=py37-pytest54-xdist33-coverage45 + - env: TOXENV=py37-pytest54-xdist133-coverage55 python: '3.7' - - env: TOXENV=py37-pytest54-xdist33-coverage52 - python: '3.7' - - env: TOXENV=py38-pytest46-xdist33-coverage45 - python: '3.8' - - env: TOXENV=py38-pytest46-xdist33-coverage52 + - env: TOXENV=py38-pytest46-xdist133-coverage55 python: '3.8' - - env: TOXENV=py38-pytest54-xdist33-coverage45 + - env: TOXENV=py38-pytest54-xdist133-coverage55 python: '3.8' - - env: TOXENV=py38-pytest54-xdist33-coverage52 - python: '3.8' - - env: TOXENV=pypy3-pytest46-xdist33-coverage45 - python: 'pypy3' - - env: TOXENV=pypy3-pytest46-xdist33-coverage52 - python: 'pypy3' - - env: TOXENV=pypy3-pytest54-xdist33-coverage45 + - env: TOXENV=pypy3-pytest46-xdist133-coverage55 python: 'pypy3' - - env: TOXENV=pypy3-pytest54-xdist33-coverage52 + - env: TOXENV=pypy3-pytest54-xdist133-coverage55 python: 'pypy3' - - env: TOXENV=py36-pytest60-xdist200-coverage52 + - env: TOXENV=py36-pytest62-xdist202-coverage55 python: '3.6' - - env: TOXENV=py37-pytest60-xdist200-coverage52 + - env: TOXENV=py37-pytest62-xdist202-coverage55 python: '3.7' - - env: TOXENV=py38-pytest60-xdist200-coverage52 + - env: TOXENV=py38-pytest62-xdist202-coverage55 python: '3.8' - - env: TOXENV=pypy3-pytest60-xdist200-coverage52 + - env: TOXENV=py39-pytest62-xdist202-coverage55 + python: '3.9' + - env: TOXENV=pypy3-pytest62-xdist202-coverage55 python: 'pypy3' - stage: examples diff --git a/AUTHORS.rst b/AUTHORS.rst index a7688685..d3d01d11 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -39,3 +39,10 @@ Authors * Michael Manganiello - https://github.com/adamantike * Anders Hovmöller - https://github.com/boxed * Zac Hatfield-Dodds - https://zhd.dev +* Mateus Berardo de Souza Terra - https://github.com/MatTerra +* Ganden Schaffner - https://github.com/gschaffner +* Michał Górny - https://github.com/mgorny +* Bernát Gábor - https://github.com/gaborbernat +* Pamela McA'Nulty - https://github.com/PamelaM +* Christian Riedel - https://github.com/Cielquan +* Chris Sreesangkom - https://github.com/csreesan diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 52c35136..23e9a3b9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,11 +1,51 @@ Changelog ========= -2.10.1 (2020-06-??) + +2.12.0 (2021-05-14) +------------------- + +* Added coverage's `toml` extra to install requirements in setup.py. + Contributed by Christian Riedel in `#410 `_. +* Fixed ``pytest_cov.__version__`` to have the right value (string with version instead of a string + including ``__version__ =``). +* Fixed license classifier in ``setup.py``. + Contributed by Chris Sreesangkom in `#467 `_. +* Fixed *commits since* badge. + Contributed by Terence Honles in `#470 `_. + +2.11.1 (2021-01-20) +------------------- + +* Fixed support for newer setuptools (v42+). + Contributed by Michał Górny in `#451 `_. + +2.11.0 (2021-01-18) +------------------- + +* Bumped minimum coverage requirement to 5.2.1. This prevents reporting issues. + Contributed by Mateus Berardo de Souza Terra in `#433 `_. +* Improved sample projects (from the `examples `_ + directory) to support running `tox -e pyXY`. Now the example configures a suffixed coverage data file, + and that makes the cleanup environment unnecessary. + Contributed by Ganden Schaffner in `#435 `_. +* Removed the empty `console_scripts` entrypoint that confused some Gentoo build script. + I didn't ask why it was so broken cause I didn't want to ruin my day. + Contributed by Michał Górny in `#434 `_. +* Fixed the missing `coverage context `_ + when using subprocesses. + Contributed by Bernát Gábor in `#443 `_. +* Updated the config section in the docs. + Contributed by Pamela McA'Nulty in `#429 `_. +* Migrated CI to travis-ci.com (from .org). + +2.10.1 (2020-08-14) ------------------- * Support for ``pytest-xdist`` 2.0, which breaks compatibility with ``pytest-xdist`` before 1.22.3 (from 2017). Contributed by Zac Hatfield-Dodds in `#412 `_. +* Fixed the ``LocalPath has no attribute startswith`` failure that occurred when using the ``pytester`` plugin + in inline mode. 2.10.0 (2020-06-12) ------------------- diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 53f55975..f02562eb 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -74,7 +74,8 @@ For merging, you should: 4. Add yourself to ``AUTHORS.rst``. .. [1] If you don't have all the necessary python versions available locally you can rely on Travis - it will - `run the tests `_ for each change you add in the pull request. + `run the tests `_ + for each change you add in the pull request. It will be slower though ... @@ -85,6 +86,6 @@ To run a subset of tests:: tox -e envname -- pytest -k test_myfeature -To run the test environments in *parallel*:: +To run all the test environments in *parallel*:: tox -p auto diff --git a/README.rst b/README.rst index 3b6ed2a1..a0c44a71 100644 --- a/README.rst +++ b/README.rst @@ -19,9 +19,9 @@ Overview :target: https://readthedocs.org/projects/pytest-cov :alt: Documentation Status -.. |travis| image:: https://api.travis-ci.org/pytest-dev/pytest-cov.svg?branch=master +.. |travis| image:: https://api.travis-ci.com/pytest-dev/pytest-cov.svg?branch=master :alt: Travis-CI Build Status - :target: https://travis-ci.org/pytest-dev/pytest-cov + :target: https://travis-ci.com/github/pytest-dev/pytest-cov .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/pytest-dev/pytest-cov?branch=master&svg=true :alt: AppVeyor Build Status @@ -38,9 +38,9 @@ Overview .. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pytest-cov.svg :target: https://anaconda.org/conda-forge/pytest-cov -.. |commits-since| image:: https://img.shields.io/github/commits-since/pytest-dev/pytest-cov/v2.10.0.svg +.. |commits-since| image:: https://img.shields.io/github/commits-since/pytest-dev/pytest-cov/v2.12.0.svg :alt: Commits since latest release - :target: https://github.com/pytest-dev/pytest-cov/compare/v2.10.0...master + :target: https://github.com/pytest-dev/pytest-cov/compare/v2.12.0...master .. |wheel| image:: https://img.shields.io/pypi/wheel/pytest-cov.svg :alt: PyPI Wheel diff --git a/ci/templates/.appveyor.yml b/ci/templates/.appveyor.yml index 92630e15..01ca3493 100644 --- a/ci/templates/.appveyor.yml +++ b/ci/templates/.appveyor.yml @@ -1,5 +1,8 @@ version: '{branch}-{build}' build: off +image: + - Visual Studio 2015 + - Visual Studio 2019 environment: matrix: - TOXENV: check @@ -7,8 +10,26 @@ environment: - TOXENV: '{{ py35_environments|join(",") }}' - TOXENV: '{{ py36_environments|join(",") }}' - TOXENV: '{{ py37_environments|join(",") }}' + - TOXENV: '{{ py38_environments|join(",") }}' + - TOXENV: '{{ py39_environments|join(",") }}' - TOXENV: '{{ pypy_environments|join(",") }}' - + - TOXENV: '{{ pypy3_environments|join(",") }}' +matrix: + exclude: + - image: Visual Studio 2015 + TOXENV: '{{ py27_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ py36_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ py37_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ py38_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ py39_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ pypy_environments|join(",") }}' + - image: Visual Studio 2019 + TOXENV: '{{ pypy3_environments|join(",") }}' init: - ps: echo $env:TOXENV - ps: ls C:\Python* diff --git a/docs/conf.py b/docs/conf.py index ce62c430..1da75b8a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,7 @@ year = '2016' author = 'pytest-cov contributors' copyright = '{}, {}'.format(year, author) -version = release = '2.10.0' +version = release = '2.12.0' pygments_style = 'trac' templates_path = ['.'] diff --git a/docs/config.rst b/docs/config.rst index 3e5bf938..0dfb17a0 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -21,9 +21,16 @@ For full details refer to the `coverage config file`_ documentation. .. _`coverage config file`: https://coverage.readthedocs.io/en/latest/config.html -Note that this plugin controls some options and setting the option in the config file will have no -effect. These include specifying source to be measured (source option) and all data file handling -(data_file and parallel options). +.. note:: Important Note + + This plugin overrides the ``data_file`` and ``parallel`` options of coverage. Unless you also run coverage without + pytest-cov it's pointless to set those options in your ``.coveragerc``. + + If you use the ``--cov=something`` option (with a value) then coverage's ``source`` option will also get overriden. + If you have multiple sources it might be easier to set those in ``.coveragerc`` and always use ``--cov`` (wihout a value) + instead of having a long command line with ``--cov=pkg1 --cov=pkg2 --cov=pkg3 ...``. + + If you use the ``--cov-branch`` option then coverage's ``branch`` option will also get overriden. If you wish to always add pytest-cov with pytest, you can use ``addopts`` under ``pytest`` or ``tool:pytest`` section. For example: :: diff --git a/docs/xdist.rst b/docs/xdist.rst index a2da50e9..5f7bc882 100644 --- a/docs/xdist.rst +++ b/docs/xdist.rst @@ -30,7 +30,7 @@ Again but spread over different hosts and different directories:: pytest --cov=myproj --dist load --tx ssh=memedough@host1//chdir=testenv1 --tx ssh=memedough@host2//chdir=/tmp/testenv2//python=/tmp/env1/bin/python - --rsyncdir myproj --rsyncdir tests --rsync examples + --rsync examples tests/ Shows a terminal report:: diff --git a/examples/adhoc-layout/tox.ini b/examples/adhoc-layout/tox.ini index a2472d03..6e299f24 100644 --- a/examples/adhoc-layout/tox.ini +++ b/examples/adhoc-layout/tox.ini @@ -1,12 +1,14 @@ [tox] -envlist = clean,py27,py38,report +envlist = py27,py38,report [tool:pytest] addopts = --cov-report=term-missing [testenv] -commands = pytest --cov --cov-append --cov-config={toxinidir}/.coveragerc {posargs:-vv} +setenv = + py{27,38}: COVERAGE_FILE = .coverage.{envname} +commands = pytest --cov --cov-config={toxinidir}/.coveragerc {posargs:-vv} deps = pytest coverage @@ -17,7 +19,6 @@ deps = ../.. depends = - {py27,py38}: clean report: py27,py38 # note that this is necessary to prevent the tests importing the code from your badly laid project @@ -27,10 +28,6 @@ changedir = tests skip_install = true deps = coverage commands = + coverage combine coverage html coverage report --fail-under=100 - -[testenv:clean] -skip_install = true -deps = coverage -commands = coverage erase diff --git a/examples/src-layout/tox.ini b/examples/src-layout/tox.ini index 054b4b80..6be8e73d 100644 --- a/examples/src-layout/tox.ini +++ b/examples/src-layout/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = clean,py27,py38,report +envlist = py27,py38,report [tool:pytest] testpaths = tests @@ -7,7 +7,9 @@ addopts = --cov-report=term-missing [testenv] -commands = pytest --cov --cov-append {posargs:-vv} +setenv = + py{27,38}: COVERAGE_FILE = .coverage.{envname} +commands = pytest --cov {posargs:-vv} deps = pytest coverage @@ -18,17 +20,12 @@ deps = ../.. depends = - {py27,py38}: clean report: py27,py38 [testenv:report] skip_install = true deps = coverage commands = + coverage combine coverage html coverage report --fail-under=100 - -[testenv:clean] -skip_install = true -deps = coverage -commands = coverage erase diff --git a/setup.py b/setup.py index e0dd574c..ca77760c 100755 --- a/setup.py +++ b/setup.py @@ -30,24 +30,24 @@ def read(*names, **kwargs): class BuildWithPTH(build): - def run(self): - build.run(self) + def run(self, *args, **kwargs): + build.run(self, *args, **kwargs) path = join(dirname(__file__), 'src', 'pytest-cov.pth') dest = join(self.build_lib, basename(path)) self.copy_file(path, dest) class EasyInstallWithPTH(easy_install): - def run(self): - easy_install.run(self) + def run(self, *args, **kwargs): + easy_install.run(self, *args, **kwargs) path = join(dirname(__file__), 'src', 'pytest-cov.pth') dest = join(self.install_dir, basename(path)) self.copy_file(path, dest) class InstallLibWithPTH(install_lib): - def run(self): - install_lib.run(self) + def run(self, *args, **kwargs): + install_lib.run(self, *args, **kwargs) path = join(dirname(__file__), 'src', 'pytest-cov.pth') dest = join(self.install_dir, basename(path)) self.copy_file(path, dest) @@ -58,8 +58,8 @@ def get_outputs(self): class DevelopWithPTH(develop): - def run(self): - develop.run(self) + def run(self, *args, **kwargs): + develop.run(self, *args, **kwargs) path = join(dirname(__file__), 'src', 'pytest-cov.pth') dest = join(self.install_dir, basename(path)) self.copy_file(path, dest) @@ -85,7 +85,7 @@ def run(self): setup( name='pytest-cov', - version='2.10.0', + version='2.12.0', license='MIT', description='Pytest plugin for measuring coverage.', long_description='%s\n%s' % (read('README.rst'), re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))), @@ -102,7 +102,7 @@ def run(self): 'Development Status :: 5 - Production/Stable', 'Framework :: Pytest', 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', + 'License :: OSI Approved :: MIT License', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: Unix', @@ -124,7 +124,7 @@ def run(self): ], install_requires=[ 'pytest>=4.6', - 'coverage>=4.4' + 'coverage[toml]>=5.2.1' ], python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', extras_require={ @@ -141,8 +141,6 @@ def run(self): 'pytest11': [ 'pytest_cov = pytest_cov.plugin', ], - 'console_scripts': [ - ] }, cmdclass={ 'build': BuildWithPTH, diff --git a/src/pytest_cov/__init__.py b/src/pytest_cov/__init__.py index 00253580..a9f1cb62 100644 --- a/src/pytest_cov/__init__.py +++ b/src/pytest_cov/__init__.py @@ -1,2 +1,2 @@ """pytest-cov: avoid already-imported warning: PYTEST_DONT_REWRITE.""" -__version__ = "2.10.0" +__version__ = '2.12.0' diff --git a/src/pytest_cov/embed.py b/src/pytest_cov/embed.py index 7e081fee..3adecdba 100644 --- a/src/pytest_cov/embed.py +++ b/src/pytest_cov/embed.py @@ -45,6 +45,7 @@ def init(): cov_config = os.environ.get('COV_CORE_CONFIG') cov_datafile = os.environ.get('COV_CORE_DATAFILE') cov_branch = True if os.environ.get('COV_CORE_BRANCH') == 'enabled' else None + cov_context = os.environ.get('COV_CORE_CONTEXT') if cov_datafile: if _active_cov: @@ -71,6 +72,8 @@ def init(): ) cov.load() cov.start() + if cov_context: + cov.switch_context(cov_context) cov._warn_no_data = False cov._warn_unimported_source = False return cov diff --git a/src/pytest_cov/engine.py b/src/pytest_cov/engine.py index eab06564..ac66c6ff 100644 --- a/src/pytest_cov/engine.py +++ b/src/pytest_cov/engine.py @@ -110,6 +110,7 @@ def unset_env(): os.environ.pop('COV_CORE_CONFIG', None) os.environ.pop('COV_CORE_DATAFILE', None) os.environ.pop('COV_CORE_BRANCH', None) + os.environ.pop('COV_CORE_CONTEXT', None) @staticmethod def get_node_desc(platform, version_info): @@ -247,7 +248,9 @@ def start(self): # Ensure coverage rc file rsynced if appropriate. if self.cov_config and os.path.exists(self.cov_config): - self.config.option.rsyncdir.append(self.cov_config) + # rsyncdir is going away in pytest-xdist 4.0, already deprecated + if hasattr(self.config.option, 'rsyncdir'): + self.config.option.rsyncdir.append(self.cov_config) self.cov = coverage.Coverage(source=self.cov_source, branch=self.cov_branch, diff --git a/src/pytest_cov/plugin.py b/src/pytest_cov/plugin.py index 2d22b309..b875f409 100644 --- a/src/pytest_cov/plugin.py +++ b/src/pytest_cov/plugin.py @@ -356,6 +356,7 @@ def pytest_runtest_call(self, item): def switch_context(self, item, when): context = "{item.nodeid}|{when}".format(item=item, when=when) self.cov.switch_context(context) + os.environ['COV_CORE_CONTEXT'] = context @pytest.fixture diff --git a/tests/test_pytest_cov.py b/tests/test_pytest_cov.py index f0fd6caa..0d1b5a23 100644 --- a/tests/test_pytest_cov.py +++ b/tests/test_pytest_cov.py @@ -498,10 +498,6 @@ def test_central_coveragerc(testdir, prop): 'test_central_coveragerc* %s *' % prop.result, '*10 passed*', ]) - - # single-module coverage report - assert all(not line.startswith('TOTAL ') for line in result.stdout.lines[-4:]) - assert result.ret == 0 @@ -536,10 +532,6 @@ def test_central_with_path_aliasing(testdir, monkeypatch, opts, prop): 'src[\\/]mod* %s *' % prop.result, '*10 passed*', ]) - - # single-module coverage report - assert all(not line.startswith('TOTAL ') for line in result.stdout.lines[-4:]) - assert result.ret == 0 @@ -642,9 +634,6 @@ def test_show_missing_coveragerc(testdir, prop): '*10 passed*', ]) - # single-module coverage report - assert all(not line.startswith('TOTAL ') for line in result.stdout.lines[-4:]) - assert result.ret == 0 @@ -1059,7 +1048,7 @@ def test_funcarg_not_active(testdir): @pytest.mark.skipif("sys.version_info[0] < 3", reason="no context manager api on Python 2") @pytest.mark.skipif('sys.platform == "win32"', reason="multiprocessing support is broken on Windows") @pytest.mark.skipif('platform.python_implementation() == "PyPy"', reason="often deadlocks on PyPy") -@pytest.mark.skipif('sys.version_info[:2] == (3, 8)', reason="deadlocks on Python 3.8, see: https://bugs.python.org/issue38227") +@pytest.mark.skipif('sys.version_info[:2] >= (3, 8)', reason="deadlocks on Python 3.8+, see: https://bugs.python.org/issue38227") def test_multiprocessing_pool(testdir): pytest.importorskip('multiprocessing.util') @@ -1100,7 +1089,7 @@ def test_run_target(): @pytest.mark.skipif('sys.platform == "win32"', reason="multiprocessing support is broken on Windows") @pytest.mark.skipif('platform.python_implementation() == "PyPy"', reason="often deadlocks on PyPy") -@pytest.mark.skipif('sys.version_info[:2] == (3, 8)', reason="deadlocks on Python 3.8, see: https://bugs.python.org/issue38227") +@pytest.mark.skipif('sys.version_info[:2] >= (3, 8)', reason="deadlocks on Python 3.8, see: https://bugs.python.org/issue38227") def test_multiprocessing_pool_terminate(testdir): pytest.importorskip('multiprocessing.util') @@ -1538,8 +1527,14 @@ def test_cover_looponfail(testdir, monkeypatch): testdir.makeconftest(CONFTEST) script = testdir.makepyfile(BASIC_TEST) - monkeypatch.setattr(testdir, 'run', - lambda *args, **kwargs: _TestProcess(*map(str, args))) + def mock_run(*args, **kwargs): + return _TestProcess(*map(str, args)) + + monkeypatch.setattr(testdir, 'run', mock_run) + assert testdir.run is mock_run + if hasattr(testdir, '_pytester'): + monkeypatch.setattr(testdir._pytester, 'run', mock_run) + assert testdir._pytester.run is mock_run with testdir.runpytest('-v', '--cov=%s' % script.dirpath(), '--looponfail', diff --git a/tox.ini b/tox.ini index ec088198..6be986e9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,21 @@ +[testenv:bootstrap] +deps = + jinja2 + matrix + tox +skip_install = true +commands = + python ci/bootstrap.py --no-env +passenv = + * ; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist [tox] envlist = check - py{27,35,36,37,py,py3}-pytest46-xdist27-coverage{45,52} - py{36,37,38,py3}-pytest{46,54}-xdist33-coverage{45,52} - py{36,37,38,py3}-pytest{60}-xdist200-coverage{52} + py{27,35,36,37,py,py3}-pytest46-xdist127-coverage{55} + py{36,37,38,py3}-pytest{46,54}-xdist133-coverage{55} + py{36,37,38,39,py3}-pytest{62}-xdist202-coverage{55} docs [testenv] @@ -17,21 +27,28 @@ setenv = pytest46: _DEP_PYTEST=pytest==4.6.10 pytest53: _DEP_PYTEST=pytest==5.3.2 pytest54: _DEP_PYTEST=pytest==5.4.3 - pytest60: _DEP_PYTEST=pytest==6.0.1 + pytest60: _DEP_PYTEST=pytest==6.0.2 + pytest61: _DEP_PYTEST=pytest==6.1.2 + pytest62: _DEP_PYTEST=pytest==6.2.2 - xdist27: _DEP_PYTESTXDIST=pytest-xdist==1.27.0 - xdist29: _DEP_PYTESTXDIST=pytest-xdist==1.29.0 - xdist31: _DEP_PYTESTXDIST=pytest-xdist==1.31.0 - xdist32: _DEP_PYTESTXDIST=pytest-xdist==1.32.0 - xdist33: _DEP_PYTESTXDIST=pytest-xdist==1.33.0 - xdist34: _DEP_PYTESTXDIST=pytest-xdist==1.34.0 + xdist127: _DEP_PYTESTXDIST=pytest-xdist==1.27.0 + xdist129: _DEP_PYTESTXDIST=pytest-xdist==1.29.0 + xdist131: _DEP_PYTESTXDIST=pytest-xdist==1.31.0 + xdist132: _DEP_PYTESTXDIST=pytest-xdist==1.32.0 + xdist133: _DEP_PYTESTXDIST=pytest-xdist==1.33.0 + xdist134: _DEP_PYTESTXDIST=pytest-xdist==1.34.0 xdist200: _DEP_PYTESTXDIST=pytest-xdist==2.0.0 + xdist201: _DEP_PYTESTXDIST=pytest-xdist==2.1.0 + xdist202: _DEP_PYTESTXDIST=pytest-xdist==2.2.0 xdistdev: _DEP_PYTESTXDIST=git+https://github.com/pytest-dev/pytest-xdist.git#egg=pytest-xdist coverage45: _DEP_COVERAGE=coverage==4.5.4 coverage50: _DEP_COVERAGE=coverage==5.0.4 coverage51: _DEP_COVERAGE=coverage==5.1 coverage52: _DEP_COVERAGE=coverage==5.2.1 + coverage53: _DEP_COVERAGE=coverage==5.3.1 + coverage54: _DEP_COVERAGE=coverage==5.4 + coverage55: _DEP_COVERAGE=coverage==5.5 # For testing against a coverage.py working tree. coveragedev: _DEP_COVERAGE=-e{env:COVERAGE_HOME} passenv =