| 1 |
From: Adam Cecile <[email protected]> |
| 2 |
Date: Wed, 26 Aug 2020 15:42:21 +0200 |
| 3 |
Subject: Socks proxy unittest optional, |
| 4 |
depending of siosocks import availability |
| 5 |
|
| 6 |
--- |
| 7 |
tests/conftest.py | 5 ++++- |
| 8 |
tests/test_client_side_socks.py | 8 +++++++- |
| 9 |
2 files changed, 11 insertions(+), 2 deletions(-) |
| 10 |
|
| 11 |
diff --git a/tests/conftest.py b/tests/conftest.py |
| 12 |
index 61a719c..21b9e96 100644 |
| 13 |
--- a/tests/conftest.py |
| 14 |
+++ b/tests/conftest.py |
| 15 |
@@ -13,7 +13,10 @@ import pytest |
| 16 |
import pytest_asyncio |
| 17 |
import trustme |
| 18 |
from async_timeout import timeout |
| 19 |
|
| 20 |
+try: |
| 21 |
+ from siosocks.io.asyncio import socks_server_handler |
| 22 |
+except ImportError: |
| 23 |
+ pass |
| 24 |
|
| 25 |
import aioftp |
| 26 |
|
| 27 |
diff --git a/tests/test_client_side_socks.py b/tests/test_client_side_socks.py |
| 28 |
index cebf705..f4562e4 100644 |
| 29 |
--- a/tests/test_client_side_socks.py |
| 30 |
+++ b/tests/test_client_side_socks.py |
| 31 |
@@ -1,7 +1,12 @@ |
| 32 |
import pytest |
| 33 |
|
| 34 |
+try: |
| 35 |
+ from siosocks.exceptions import SocksException |
| 36 |
+ HAS_SIOSOCKS = True |
| 37 |
+except ImportError: |
| 38 |
+ HAS_SIOSOCKS = False |
| 39 |
|
| 40 |
|
| 41 |
[email protected](not HAS_SIOSOCKS, reason="requires siosocks package") |
| 42 |
@pytest.mark.asyncio |
| 43 |
async def test_socks_success(pair_factory, Client, socks): |
| 44 |
client = Client( |
| 45 |
@@ -15,6 +20,7 @@ async def test_socks_success(pair_factory, Client, socks): |
| 46 |
pass |
| 47 |
|
| 48 |
|
| 49 |
[email protected](not HAS_SIOSOCKS, reason="requires siosocks package") |
| 50 |
@pytest.mark.asyncio |
| 51 |
async def test_socks_fail(pair_factory, Client, socks): |
| 52 |
client = Client( |