From 68ab2e0bbbeca9efa38a92c2646429f781a349ea Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Fri, 30 Dec 2022 16:18:54 +0100 Subject: [PATCH] Use hatch-autorun instead of coverage-enable-subprocess --- pyproject.toml | 12 ++++++++++-- tox.ini | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 58e8576fc..136e1ef11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,8 +50,6 @@ tests-no-zope = [ tests = ["attrs[tests-no-zope]", "zope.interface"] cov = [ "attrs[tests]", - # Makes coverage work with pytest-xdist. - "coverage-enable-subprocess", # Ensure coverage is new enough for `source_pkgs`. "coverage>=5.3", ] @@ -115,6 +113,16 @@ text = """ """ +# Make coverage play nicely with pytest-xdist. +[tool.hatch.build.targets.wheel.hooks.autorun] +dependencies = ["hatch-autorun"] +code = """ +import coverage +coverage.process_startup() +""" +enable-by-default = false + + [tool.pytest.ini_options] addopts = ["-ra", "--strict-markers", "--strict-config"] xfail_strict = true diff --git a/tox.ini b/tox.ini index 9969b932f..fc58b5ede 100644 --- a/tox.ini +++ b/tox.ini @@ -31,7 +31,9 @@ commands = python -m pytest {posargs:-n auto} [testenv:py37] extras = cov -setenv = COVERAGE_PROCESS_START={toxinidir}/pyproject.toml +setenv = + HATCH_BUILD_HOOK_ENABLE_AUTORUN=1 + COVERAGE_PROCESS_START={toxinidir}/pyproject.toml commands = coverage run -m pytest {posargs:-n auto}