From c55b4d0792d4a83a87c0c29fc2489b961a60d222 Mon Sep 17 00:00:00 2001 From: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:22:17 -0700 Subject: [PATCH] Fix aiohttp Failures (#1123) * Update aiohttp in tests * Remove unnecessary and buggy tests * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: TimPansino --- .../test_client_async_await.py | 67 +------------------ tox.ini | 3 +- 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/tests/framework_aiohttp/test_client_async_await.py b/tests/framework_aiohttp/test_client_async_await.py index dedc64c9d..21278a92b 100644 --- a/tests/framework_aiohttp/test_client_async_await.py +++ b/tests/framework_aiohttp/test_client_async_await.py @@ -17,7 +17,9 @@ import aiohttp import pytest from testing_support.fixtures import cat_enabled -from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.validators.validate_transaction_metrics import ( + validate_transaction_metrics, +) from yarl import URL from newrelic.api.background_task import background_task @@ -114,68 +116,6 @@ def task_test(): task_test() -@pytest.mark.parametrize("method,exc_expected", test_matrix) -def test_client_throw_async_await(event_loop, local_server_info, method, exc_expected): - class ThrowerException(ValueError): - pass - - @background_task(name="test_client_throw_async_await") - async def self_driving_thrower(): - async with aiohttp.ClientSession() as session: - coro = session._request(method.upper(), local_server_info.url) - - # activate the coroutine - coro.send(None) - - # inject error - coro.throw(ThrowerException()) - - @validate_transaction_metrics( - "test_client_throw_async_await", - background_task=True, - scoped_metrics=[ - (local_server_info.base_metric + method.upper(), 1), - ], - rollup_metrics=[ - (local_server_info.base_metric + method.upper(), 1), - ], - ) - def task_test(): - with pytest.raises(ThrowerException): - event_loop.run_until_complete(self_driving_thrower()) - - task_test() - - -@pytest.mark.parametrize("method,exc_expected", test_matrix) -def test_client_close_async_await(event_loop, local_server_info, method, exc_expected): - @background_task(name="test_client_close_async_await") - async def self_driving_closer(): - async with aiohttp.ClientSession() as session: - coro = session._request(method.upper(), local_server_info.url) - - # activate the coroutine - coro.send(None) - - # force close - coro.close() - - @validate_transaction_metrics( - "test_client_close_async_await", - background_task=True, - scoped_metrics=[ - (local_server_info.base_metric + method.upper(), 1), - ], - rollup_metrics=[ - (local_server_info.base_metric + method.upper(), 1), - ], - ) - def task_test(): - event_loop.run_until_complete(self_driving_closer()) - - task_test() - - @pytest.mark.parametrize("method,exc_expected", test_matrix) @cat_enabled def test_await_request_async_await(event_loop, local_server_info, method, exc_expected): @@ -240,7 +180,6 @@ def task_test(): @pytest.mark.parametrize("method,exc_expected", test_matrix) @cat_enabled def test_create_task_async_await(event_loop, local_server_info, method, exc_expected): - # `loop.create_task` returns a Task object which uses the coroutine's # `send` method, not `__next__` diff --git a/tox.ini b/tox.ini index 1c4bdf8f6..3038c612e 100644 --- a/tox.ini +++ b/tox.ini @@ -114,8 +114,7 @@ envlist = python-external_requests-{py27,py37,py38,py39,py310,py311,py312,pypy27,pypy310}, python-external_urllib3-{py27,py37,py38,py39,py310,py311,py312,pypy27,pypy310}-urllib3latest, python-external_urllib3-{py27,py37,pypy27}-urllib3{0109}, - python-framework_aiohttp-{py37,py38,py39,py310,py311,pypy310}-aiohttp03, - python-framework_aiohttp-py312-aiohttp030900rc0, + python-framework_aiohttp-{py37,py38,py39,py310,py311,py312,pypy310}-aiohttp03, python-framework_ariadne-{py37,py38,py39,py310,py311,py312}-ariadnelatest, python-framework_ariadne-py37-ariadne{0011,0012,0013}, python-framework_bottle-{py27,py37,py38,py39,py310,py311,py312,pypy27,pypy310}-bottle0012,