From c330e7321fe84b3bbb393e523b3ffe47b40f0e5d Mon Sep 17 00:00:00 2001 From: Lucas Tierney Date: Wed, 24 Apr 2019 20:05:43 -0500 Subject: [PATCH] update tests to work with python 2 and 3 --- .travis.yml | 1 - tests/SmokeTests/__init__.py | 8 ++++++-- tests/test.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e60ccd8857..35b88e439f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: python -python: 2.7 sudo: required diff --git a/tests/SmokeTests/__init__.py b/tests/SmokeTests/__init__.py index e5585cddb4..d477d4d95c 100644 --- a/tests/SmokeTests/__init__.py +++ b/tests/SmokeTests/__init__.py @@ -1,8 +1,12 @@ import unittest -import urllib2 import time import json +try: + from urllib2 import urlopen +except ImportError: + from urllib.request import urlopen + class SmokeTests(unittest.TestCase): def smoke_test_container(self, port): @@ -15,7 +19,7 @@ def smoke_test_container(self, port): while current_attempts < max_attempts: current_attempts = current_attempts + 1 try: - response = urllib2.urlopen('http://localhost:%s/wd/hub/status' % port) + response = urlopen('http://localhost:%s/wd/hub/status' % port) status_json = json.loads(response.read()) self.assertTrue(status_json['value']['ready'], "Container is not ready on port %s" % port) status_fetched = True diff --git a/tests/test.py b/tests/test.py index dc9941a46e..f5d2648af0 100644 --- a/tests/test.py +++ b/tests/test.py @@ -161,7 +161,7 @@ def launch_container(container, **kwargs): test_runner = unittest.TextTestRunner(verbosity=3) failed = not test_runner.run(suite).wasSuccessful() except Exception as e: - logger.fatal(e.message) + logger.fatal(e) failed = True try: @@ -172,7 +172,7 @@ def launch_container(container, **kwargs): test_runner = unittest.TextTestRunner(verbosity=3) failed = not test_runner.run(suite).wasSuccessful() except Exception as e: - logger.fatal(e.message) + logger.fatal(e) failed = True logger.info("Cleaning up...")