1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-06 10:24:24 +00:00

Fix tracking of coverage in subprocesses.

This commit is contained in:
Andrey Rakhmatullin 2025-01-07 19:11:10 +05:00
parent 59fcb9b93c
commit 7dfbecd392
3 changed files with 11 additions and 12 deletions

View File

@ -120,6 +120,12 @@ include = ["scrapy/*"]
omit = ["tests/*"]
disable_warnings = ["include-ignored"]
[tool.coverage.paths]
source = [
"scrapy",
".tox/**/site-packages/scrapy"
]
[tool.coverage.report]
# https://github.com/nedbat/coveragepy/issues/831#issuecomment-517778185
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]

View File

@ -15,13 +15,6 @@ os.environ["http_proxy"] = ""
os.environ["https_proxy"] = ""
os.environ["ftp_proxy"] = ""
# Absolutize paths to coverage config and output file because tests that
# spawn subprocesses also changes current working directory.
_sourceroot = Path(__file__).resolve().parent.parent
if "COV_CORE_CONFIG" in os.environ:
os.environ["COVERAGE_FILE"] = str(_sourceroot / ".coverage")
os.environ["COV_CORE_CONFIG"] = str(_sourceroot / os.environ["COV_CORE_CONFIG"])
tests_datadir = str(Path(__file__).parent.resolve() / "sample_data")

10
tox.ini
View File

@ -14,7 +14,7 @@ deps =
pyftpdlib >= 2.0.1
pygments
pytest
pytest-cov==4.0.0
pytest-cov >= 4.0.0
pytest-xdist
sybil >= 1.3.0 # https://github.com/cjw296/sybil/issues/20#issuecomment-605433422
testfixtures
@ -36,7 +36,7 @@ passenv =
#allow tox virtualenv to upgrade pip/wheel/setuptools
download = true
commands =
pytest --cov=scrapy --cov-report=xml --cov-report= {posargs:--durations=10 docs scrapy tests} --doctest-modules
pytest --cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= {posargs:--durations=10 docs scrapy tests} --doctest-modules
install_command =
python -I -m pip install -ctests/upper-constraints.txt {opts} {packages}
@ -115,7 +115,7 @@ setenv =
install_command =
python -I -m pip install {opts} {packages}
commands =
pytest --cov=scrapy --cov-report=xml --cov-report= {posargs:--durations=10 scrapy tests}
pytest --cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= {posargs:--durations=10 scrapy tests}
[testenv:pinned]
basepython = {[pinned]basepython}
@ -241,7 +241,7 @@ deps =
{[testenv]deps}
botocore>=1.4.87
commands =
pytest --cov=scrapy --cov-report=xml --cov-report= {posargs:tests -m requires_botocore}
pytest --cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= {posargs:tests -m requires_botocore}
[testenv:botocore-pinned]
basepython = {[pinned]basepython}
@ -252,4 +252,4 @@ install_command = {[pinned]install_command}
setenv =
{[pinned]setenv}
commands =
pytest --cov=scrapy --cov-report=xml --cov-report= {posargs:tests -m requires_botocore}
pytest --cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= {posargs:tests -m requires_botocore}