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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
From: Adam Cecile <acecile@letz-it.lu>
Date: Wed, 26 Aug 2020 15:42:21 +0200
Subject: Socks proxy unittest optional,
depending of siosocks import availability
---
tests/conftest.py | 5 ++++-
tests/test_client_side_socks.py | 8 +++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 61a719c..21b9e96 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -13,7 +13,10 @@ import pytest
import pytest_asyncio
import trustme
from async_timeout import timeout
-from siosocks.io.asyncio import socks_server_handler
+try:
+ from siosocks.io.asyncio import socks_server_handler
+except ImportError:
+ pass
import aioftp
diff --git a/tests/test_client_side_socks.py b/tests/test_client_side_socks.py
index cebf705..f4562e4 100644
--- a/tests/test_client_side_socks.py
+++ b/tests/test_client_side_socks.py
@@ -1,7 +1,12 @@
import pytest
-from siosocks.exceptions import SocksException
+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(
@@ -15,6 +20,7 @@ async def test_socks_success(pair_factory, Client, socks):
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(
|