From a4f7ff0ac2725e2ce932e20d02fce574ea791bb1 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 8 Aug 2023 15:32:46 +0200 Subject: [PATCH 1/2] Testing: run Coverage report only on CircleCI due to Python debugger I've been hitting an issue while debugging test cases that it doesn't stop exactly where I put the breakpoint. This has been pretty annoying since I'm in the middle of an inner function and I have to do multiple steps forward to find the exact place where I put my breakpoint. Today I found this problem is due to an incompatibility of `pytest-cov` and the debuggers: https://pytest-cov.readthedocs.io/en/latest/debuggers.html. --- .circleci/config.yml | 1 + tox.ini | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ba8f8b8abe0..806f4c2356e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,6 +15,7 @@ jobs: environment: discovery.type: single-node ES_JAVA_OPTS: -Xms750m -Xmx750m + PYTEST_COVERAGE: --cov-report=xml --cov-config .coveragerc --cov=. --cov-append steps: - checkout - run: git submodule sync diff --git a/tox.ini b/tox.ini index 03b74e40bd3..8043aa0dc70 100644 --- a/tox.ini +++ b/tox.ini @@ -16,14 +16,16 @@ deps = -r requirements/testing.txt basepython = python3.10 +# https://pytest-cov.readthedocs.io/en/latest/debuggers.html +# https://github.com/microsoft/vscode-python/issues/693 commands = sh -c '\ export DJANGO_SETTINGS_MODULE=readthedocs.settings.test; \ - pytest --cov-report=xml --cov-config .coveragerc --cov=. --pyargs readthedocs --suppress-no-test-exit-code -m "not proxito and not embed_api" {posargs:{env:TOX_POSARGS:-m "not search and not proxito and not embed_api"}}' + pytest {env:PYTEST_COVERAGE} --pyargs readthedocs --suppress-no-test-exit-code -m "not proxito and not embed_api" {posargs:{env:TOX_POSARGS:-m "not search and not proxito and not embed_api"}}' sh -c '\ export DJANGO_SETTINGS_MODULE=readthedocs.settings.proxito.test; \ - pytest --cov-report=xml --cov-config .coveragerc --cov=. --cov-append --pyargs readthedocs -m proxito --suppress-no-test-exit-code {posargs}' + pytest {env:PYTEST_COVERAGE} --pyargs readthedocs -m proxito --suppress-no-test-exit-code {posargs}' allowlist_externals = sh git From 64c5c750c4ec6a53ebb07503dcd29307533e06ac Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 10 Aug 2023 11:41:09 +0200 Subject: [PATCH 2/2] Declare the variable in the Python Docker container --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 806f4c2356e..6a6176f6d72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,12 +10,12 @@ jobs: - image: 'cimg/python:3.10' environment: TOX_POSARGS: '' + PYTEST_COVERAGE: --cov-report=xml --cov-config .coveragerc --cov=. --cov-append - image: 'docker.elastic.co/elasticsearch/elasticsearch:7.14.0' name: search environment: discovery.type: single-node ES_JAVA_OPTS: -Xms750m -Xmx750m - PYTEST_COVERAGE: --cov-report=xml --cov-config .coveragerc --cov=. --cov-append steps: - checkout - run: git submodule sync