Skip to content

Commit a3d1bee

Browse files
committed
URLError compatibility issue
1 parent 94cd30d commit a3d1bee

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

tests/src/OneLogin/saml2_tests/idp_metadata_parser_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
# Copyright (c) 2014, OneLogin, Inc.
44
# All rights reserved.
55

6+
try:
7+
from urllib.error import URLError
8+
except:
9+
from urllib2 import URLError
610

711
from copy import deepcopy
812
import json
913
from os.path import dirname, join, exists
1014
from lxml.etree import XMLSyntaxError
1115
import unittest
12-
import urllib
1316

1417
from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser
1518
from onelogin.saml2.constants import OneLogin_Saml2_Constants
@@ -50,7 +53,7 @@ def testGetMetadata(self):
5053
try:
5154
data = OneLogin_Saml2_IdPMetadataParser.get_metadata('https://www.testshib.org/metadata/testshib-providers.xml')
5255
self.assertTrue(data is not None and data is not {})
53-
except urllib.error.URLError:
56+
except URLError:
5457
pass
5558

5659
def testParseRemote(self):
@@ -62,7 +65,7 @@ def testParseRemote(self):
6265

6366
try:
6467
data = OneLogin_Saml2_IdPMetadataParser.parse_remote('https://www.testshib.org/metadata/testshib-providers.xml')
65-
except urllib.error.URLError:
68+
except URLError:
6669
xml = self.file_contents(join(self.data_path, 'metadata', 'testshib-providers.xml'))
6770
data = OneLogin_Saml2_IdPMetadataParser.parse(xml)
6871

@@ -144,7 +147,7 @@ def test_parse_testshib_required_binding_sso_redirect(self):
144147
try:
145148
xmldoc = OneLogin_Saml2_IdPMetadataParser.get_metadata(
146149
'https://www.testshib.org/metadata/testshib-providers.xml')
147-
except urllib.error.URLError:
150+
except URLError:
148151
xmldoc = self.file_contents(join(self.data_path, 'metadata', 'testshib-providers.xml'))
149152

150153
# Parse, require SSO REDIRECT binding, implicitly.
@@ -181,7 +184,7 @@ def test_parse_testshib_required_binding_sso_post(self):
181184
try:
182185
xmldoc = OneLogin_Saml2_IdPMetadataParser.get_metadata(
183186
'https://www.testshib.org/metadata/testshib-providers.xml')
184-
except urllib.error.URLError:
187+
except URLError:
185188
xmldoc = self.file_contents(join(self.data_path, 'metadata', 'testshib-providers.xml'))
186189

187190
# Parse, require POST binding.

0 commit comments

Comments
 (0)