TechDebt - Unpin coverage-dependency to speed up Py3.11 (#5629)

This commit is contained in:
Bert Blommers 2022-11-02 20:00:51 -01:00 committed by GitHub
parent 8a3b4d519a
commit ecafc89153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 3 deletions

View File

@ -104,8 +104,6 @@ jobs:
pip install -r requirements-dev.txt pip install -r requirements-dev.txt
pip install pytest-cov pip install pytest-cov
pip install pytest-github-actions-annotate-failures pip install pytest-github-actions-annotate-failures
# https://github.com/aws/aws-xray-sdk-python/issues/196
pip install "coverage<=4.5.4"
- name: Test with pytest - name: Test with pytest
run: | run: |
make test-only make test-only
@ -153,7 +151,6 @@ jobs:
- name: Install project dependencies - name: Install project dependencies
run: | run: |
pip install -r requirements-dev.txt pip install -r requirements-dev.txt
pip install "coverage<=4.5.4"
- name: Test ServerMode/Coverage - name: Test ServerMode/Coverage
env: env:
TEST_SERVER_MODE: ${{ true }} TEST_SERVER_MODE: ${{ true }}

View File

@ -37,6 +37,8 @@ test-only:
rm -f .coverage rm -f .coverage
rm -rf cover rm -rf cover
pytest -sv --cov=moto --cov-report xml ./tests/ $(TEST_EXCLUDE) pytest -sv --cov=moto --cov-report xml ./tests/ $(TEST_EXCLUDE)
# https://github.com/aws/aws-xray-sdk-python/issues/196 - Run these tests separately without Coverage enabled
pytest -sv ./tests/test_xray
MOTO_CALL_RESET_API=false pytest --cov=moto --cov-report xml --cov-append -n 4 $(PARALLEL_TESTS) MOTO_CALL_RESET_API=false pytest --cov=moto --cov-report xml --cov-append -n 4 $(PARALLEL_TESTS)
test: lint test-only test: lint test-only

View File

@ -1,3 +1,4 @@
coverage
pytest pytest
pytest-cov pytest-cov
pytest-xdist pytest-xdist

View File

@ -1,6 +1,11 @@
import os
from moto import mock_xray_client, XRaySegment, mock_dynamodb from moto import mock_xray_client, XRaySegment, mock_dynamodb
from moto.utilities.distutils_version import LooseVersion
from unittest import SkipTest
import sure # noqa # pylint: disable=unused-import import sure # noqa # pylint: disable=unused-import
import boto3 import boto3
import sys
from moto.xray.mock_client import MockEmitter from moto.xray.mock_client import MockEmitter
import aws_xray_sdk.core as xray_core import aws_xray_sdk.core as xray_core
@ -18,9 +23,27 @@ original_session_request = requests.Session.request
original_session_prep_request = requests.Session.prepare_request original_session_prep_request = requests.Session.prepare_request
def check_coverage_status():
# If the wrong version of the coverage module is loaded, skip this test
coverage_module = sys.modules.get("coverage")
# If Coverage is not installed, we're fine
if not coverage_module:
return
coverage_version = LooseVersion(coverage_module.__version__)
# If we have an old version of Coverage installed, we're fine
if coverage_version < LooseVersion("5.0.0"):
return
# If Coverage is not enabled in this test run, we're fine
if "COV_CORE_SOURCE" not in os.environ:
return
raise SkipTest("Can't run this test with Coverage 5.x")
@mock_xray_client @mock_xray_client
@mock_dynamodb @mock_dynamodb
def test_xray_dynamo_request_id(): def test_xray_dynamo_request_id():
check_coverage_status()
# Could be ran in any order, so we need to tell sdk that its been unpatched # Could be ran in any order, so we need to tell sdk that its been unpatched
xray_core_patcher._PATCHED_MODULES = set() xray_core_patcher._PATCHED_MODULES = set()
xray_core.patch_all() xray_core.patch_all()
@ -46,6 +69,8 @@ def test_xray_dynamo_request_id():
def test_xray_dynamo_request_id_with_context_mgr(): def test_xray_dynamo_request_id_with_context_mgr():
check_coverage_status()
with mock_xray_client(): with mock_xray_client():
assert isinstance(xray_core.xray_recorder._emitter, MockEmitter) assert isinstance(xray_core.xray_recorder._emitter, MockEmitter)
with mock_dynamodb(): with mock_dynamodb():
@ -82,6 +107,8 @@ def test_xray_dynamo_request_id_with_context_mgr():
@mock_xray_client @mock_xray_client
def test_xray_udp_emitter_patched(): def test_xray_udp_emitter_patched():
check_coverage_status()
# Could be ran in any order, so we need to tell sdk that its been unpatched # Could be ran in any order, so we need to tell sdk that its been unpatched
xray_core_patcher._PATCHED_MODULES = set() xray_core_patcher._PATCHED_MODULES = set()
xray_core.patch_all() xray_core.patch_all()
@ -96,6 +123,8 @@ def test_xray_udp_emitter_patched():
@mock_xray_client @mock_xray_client
def test_xray_context_patched(): def test_xray_context_patched():
check_coverage_status()
# Could be ran in any order, so we need to tell sdk that its been unpatched # Could be ran in any order, so we need to tell sdk that its been unpatched
xray_core_patcher._PATCHED_MODULES = set() xray_core_patcher._PATCHED_MODULES = set()
xray_core.patch_all() xray_core.patch_all()