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
711from copy import deepcopy
812import json
913from os .path import dirname , join , exists
1014from lxml .etree import XMLSyntaxError
1115import unittest
12- import urllib
1316
1417from onelogin .saml2 .idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser
1518from 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