From 42bce570cac2a9ff12352701f8e32d5d49112be4 Mon Sep 17 00:00:00 2001 From: yatin Date: Wed, 26 Dec 2018 17:58:00 +0530 Subject: [PATCH] Fix python3 Compatibility for urllib2 The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error [1]. This patch makes code compatible for both python2 and python3 by using six.moves.urllib [2]. [1] https://docs.python.org/2/library/urllib2.html [2] https://pythonhosted.org/six/ Change-Id: Ie9ebe0d1e39ddb4704df067d42915204e49821cf Closes-Bug: #1809801 --- ec2api_tempest_plugin/scenario/test_vpn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ec2api_tempest_plugin/scenario/test_vpn.py b/ec2api_tempest_plugin/scenario/test_vpn.py index 64a6bf4..3cdcd6a 100644 --- a/ec2api_tempest_plugin/scenario/test_vpn.py +++ b/ec2api_tempest_plugin/scenario/test_vpn.py @@ -15,9 +15,9 @@ import os import six +from six.moves.urllib.request import urlopen import sys import time -import urllib2 from lxml import etree from oslo_log import log @@ -83,7 +83,7 @@ class VpnTest(scenario_base.BaseScenarioTest): def test_vpn_connectivity(self): is_amazon = 'amazon' in CONF.aws.ec2_url - response = urllib2.urlopen(self.OPENSWAN_LINK, timeout=30) + response = urlopen(self.OPENSWAN_LINK, timeout=30) content = response.read() if not is_amazon: # NOTE(andrey-mp): gating in openstack doesn't have internet access