From 36447c97a0036592d3748fbe594928ae9c76d5af Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 23 Dec 2018 17:36:00 +0100 Subject: Skip test if invalid domain exists Must not exist for this test. --- crocoite/test_browser.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'crocoite') diff --git a/crocoite/test_browser.py b/crocoite/test_browser.py index 5616fcf..8a8d81f 100644 --- a/crocoite/test_browser.py +++ b/crocoite/test_browser.py @@ -18,7 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -import asyncio +import asyncio, socket import pytest from operator import itemgetter from aiohttp import web @@ -259,12 +259,22 @@ async def test_crash (loader): @pytest.mark.asyncio async def test_invalidurl (loader): - url = 'http://nonexistent.example/' - async with loader (url) as l: - await l.start () - async for it in l: - assert it.failed - break + host = 'nonexistent.example' + + # make sure the url does *not* resolve (some DNS intercepting ISP’s mess + # with this) + loop = asyncio.get_event_loop () + try: + resolved = await loop.getaddrinfo (host, None) + except socket.gaierror: + async with loader (f'http://{host}/') as l: + await l.start () + async for it in l: + assert it.failed + break + else: + pytest.skip (f'host {host} resolved to {resolved}') + @pytest.mark.asyncio async def test_varchangeevent (): -- cgit v1.2.3