From bd405f1b4115bd599c1610ff02b64bf0f3deb292 Mon Sep 17 00:00:00 2001 From: Andrii Date: Sat, 15 Jun 2024 21:46:33 +0300 Subject: [PATCH 1/3] update dependencies --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index b321072..3e1989c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -aiohttp>=3.4.4 +aiohttp>=3.9.5 certifi>=2018.11.29 -attrs>=19.3.0 +attrs>=23.2.0 From f459605772a8242183fda5c2e67494c67901b1b5 Mon Sep 17 00:00:00 2001 From: Andrii Date: Sat, 15 Jun 2024 21:57:52 +0300 Subject: [PATCH 2/3] update code to match latest aiohttp interfaces --- aiograph/api.py | 12 +++++------- tests/test_features.py | 14 +++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/aiograph/api.py b/aiograph/api.py index edcd6c3..5073935 100644 --- a/aiograph/api.py +++ b/aiograph/api.py @@ -1,11 +1,9 @@ import asyncio - import contextlib -from contextvars import ContextVar - import os import secrets import ssl +from contextvars import ContextVar from pathlib import Path from typing import List, Optional, Union @@ -112,19 +110,19 @@ def __init__(self, ssl_context = ssl.create_default_context(cafile=certifi.where()) if isinstance(proxy, str) and (proxy.startswith('socks5://') or proxy.startswith('socks4://')): - from aiohttp_socks import SocksConnector + from aiohttp_socks import ProxyConnector from aiohttp_socks.utils import parse_proxy_url - socks_ver, host, port, username, password = parse_proxy_url(proxy) + proxy_type, host, port, username, password = parse_proxy_url(proxy) if proxy_auth: if not username: username = proxy_auth.login if not password: password = proxy_auth.password - connector = SocksConnector(socks_ver=socks_ver, host=host, port=port, + connector = ProxyConnector(proxy_type=proxy_type, host=host, port=port, username=username, password=password, - limit=connections_limit, ssl_context=ssl_context, + limit=connections_limit, ssl=ssl_context, rdns=True, loop=self.loop) self.proxy = None diff --git a/tests/test_features.py b/tests/test_features.py index 9559e6e..7c8d8c4 100644 --- a/tests/test_features.py +++ b/tests/test_features.py @@ -1,6 +1,6 @@ import pytest from aiohttp import BasicAuth -from aiohttp_socks import SocksConnector, SocksVer +from aiohttp_socks import SocksVer, ProxyConnector from aiograph import Telegraph, types from aiograph.utils import exceptions @@ -94,9 +94,9 @@ def test_socks5_proxy(): telegraph = Telegraph(proxy='socks5://example.com:1050', proxy_auth=BasicAuth('username', 'password')) connector = telegraph.session._connector - assert isinstance(connector, SocksConnector) - assert connector._socks_ver.value == SocksVer.SOCKS5 - assert connector._socks_host == 'example.com' - assert connector._socks_port == 1050 - assert connector._socks_username == 'username' - assert connector._socks_password == 'password' + assert isinstance(connector, ProxyConnector) + assert connector._proxy_type.value == SocksVer.SOCKS5 + assert connector._proxy_host == 'example.com' + assert connector._proxy_port == 1050 + assert connector._proxy_username == 'username' + assert connector._proxy_password == 'password' From 952efac03a4392df03387fed55c699fc9fd75e00 Mon Sep 17 00:00:00 2001 From: Andrii Date: Sat, 15 Jun 2024 21:58:22 +0300 Subject: [PATCH 3/3] use `@pytest_asyncio.fixture` instead of `@pytest.yield_fixture` --- tests/conftest.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c37be1e..b882199 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import sys from pathlib import Path -import pytest +import pytest_asyncio sys.path.insert(0, str(Path(__file__).parent.parent)) @@ -10,8 +10,7 @@ access_token = None -@pytest.yield_fixture() -@pytest.mark.asyncio +@pytest_asyncio.fixture async def telegraph(): aiograph = Telegraph(token=access_token) yield aiograph