Blob Blame History Raw
From d6a22936b8b7bba39ad949624de73f40770db035 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 11 Jun 2019 15:52:47 +0200
Subject: [PATCH] Handle test failure when no network connection

---
 css_parser_tests/test_parse.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/css_parser_tests/test_parse.py b/css_parser_tests/test_parse.py
index 2f6ef426e3..ef18340a46 100644
--- a/css_parser_tests/test_parse.py
+++ b/css_parser_tests/test_parse.py
@@ -10,9 +10,9 @@ import css_parser
 from . import basetest
 
 if sys.version_info.major > 2:
-    from urllib.error import HTTPError
+    from urllib.error import HTTPError, URLError
 else:
-    from urllib2 import HTTPError
+    from urllib2 import HTTPError, URLError
 
 
 class CSSParserTestCase(basetest.BaseTestCase):
@@ -142,7 +142,8 @@ class CSSParserTestCase(basetest.BaseTestCase):
 
         self.assertRaises(ValueError, parser.parseUrl,
                           '../not-valid-in-urllib')
-        self.assertRaises(HTTPError, parser.parseUrl,
+        # we'll get an URLError if no network connection
+        self.assertRaises((HTTPError, URLError), parser.parseUrl,
                           'http://cthedot.de/not-present.css')
 
     def test_parseString(self):