1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
import pytest
try:
from siosocks.exceptions import SocksException
HAS_SIOSOCKS = True
except ImportError:
HAS_SIOSOCKS = False
@pytest.mark.skipif(not HAS_SIOSOCKS, reason="requires siosocks package")
@pytest.mark.asyncio
async def test_socks_success(pair_factory, Client, socks):
client = Client(
socks_host=socks.host,
socks_port=socks.port,
socks_version=5,
username="foo",
password="bar",
)
async with pair_factory(client):
pass
@pytest.mark.skipif(not HAS_SIOSOCKS, reason="requires siosocks package")
@pytest.mark.asyncio
async def test_socks_fail(pair_factory, Client, socks):
client = Client(
socks_host=socks.host,
socks_port=socks.port,
socks_version=5,
username="bar",
password="bar",
)
with pytest.raises(SocksException):
async with pair_factory(client):
pass
|