Skip to content

Commit c98d277

Browse files
lmtierneydiemol
authored andcommitted
update tests to work with python 2 and 3 (SeleniumHQ#899)
1 parent dfb8ee1 commit c98d277

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: python
2-
python: 2.7
32

43
sudo: required
54

tests/SmokeTests/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import unittest
2-
import urllib2
32
import time
43
import json
54

5+
try:
6+
from urllib2 import urlopen
7+
except ImportError:
8+
from urllib.request import urlopen
9+
610

711
class SmokeTests(unittest.TestCase):
812
def smoke_test_container(self, port):
@@ -15,7 +19,7 @@ def smoke_test_container(self, port):
1519
while current_attempts < max_attempts:
1620
current_attempts = current_attempts + 1
1721
try:
18-
response = urllib2.urlopen('http://localhost:%s/wd/hub/status' % port)
22+
response = urlopen('http://localhost:%s/wd/hub/status' % port)
1923
status_json = json.loads(response.read())
2024
self.assertTrue(status_json['value']['ready'], "Container is not ready on port %s" % port)
2125
status_fetched = True

tests/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def launch_container(container, **kwargs):
161161
test_runner = unittest.TextTestRunner(verbosity=3)
162162
failed = not test_runner.run(suite).wasSuccessful()
163163
except Exception as e:
164-
logger.fatal(e.message)
164+
logger.fatal(e)
165165
failed = True
166166

167167
try:
@@ -172,7 +172,7 @@ def launch_container(container, **kwargs):
172172
test_runner = unittest.TextTestRunner(verbosity=3)
173173
failed = not test_runner.run(suite).wasSuccessful()
174174
except Exception as e:
175-
logger.fatal(e.message)
175+
logger.fatal(e)
176176
failed = True
177177

178178
logger.info("Cleaning up...")

0 commit comments

Comments
 (0)