From ac8d6720bc75676e05462cc38ad144d5aedc14e7 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 21 Sep 2016 15:07:43 +0530 Subject: Migrate python code server and evaluators to python 2/3 compatible --- yaksh/tests/test_code_server.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'yaksh/tests/test_code_server.py') diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py index a73f073..1d6584b 100644 --- a/yaksh/tests/test_code_server.py +++ b/yaksh/tests/test_code_server.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import json try: from Queue import Queue @@ -5,7 +6,7 @@ except ImportError: from queue import Queue from threading import Thread import unittest -import urllib +from six.moves import urllib from yaksh.code_server import ServerPool, SERVER_POOL_PORT from yaksh import settings @@ -18,7 +19,7 @@ class TestCodeServer(unittest.TestCase): def setUpClass(cls): settings.code_evaluators['python']['standardtestcase'] = \ "yaksh.python_assertion_evaluator.PythonAssertionEvaluator" - ports = range(8001, 8006) + ports = range(8001, 8006) server_pool = ServerPool(ports=ports, pool_port=SERVER_POOL_PORT) cls.server_pool = server_pool cls.server_thread = t = Thread(target=server_pool.run) @@ -117,7 +118,8 @@ class TestCodeServer(unittest.TestCase): url = "http://localhost:%s/status"%SERVER_POOL_PORT # When - data = urllib.urlopen(url).read() + response = urllib.request.urlopen(url) + data = response.read().decode('utf-8') # Then expect = 'out of 5 are free' -- cgit