summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2018-12-23 17:36:00 +0100
committerLars-Dominik Braun <lars@6xq.net>2018-12-23 17:37:41 +0100
commit36447c97a0036592d3748fbe594928ae9c76d5af (patch)
tree8e68fa1967c6bf8e3dfb6423114e86c63884a550
parentfde26758be46f19edf68fc4e024a4c238e12cfeb (diff)
downloadcrocoite-36447c97a0036592d3748fbe594928ae9c76d5af.tar.gz
crocoite-36447c97a0036592d3748fbe594928ae9c76d5af.tar.bz2
crocoite-36447c97a0036592d3748fbe594928ae9c76d5af.zip
Skip test if invalid domain exists
Must not exist for this test.
-rw-r--r--crocoite/test_browser.py24
1 files changed, 17 insertions, 7 deletions
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 ():