未验证 提交 3b6e7a92 编写于 作者: Z Zheyue Tan 提交者: GitHub

Fix Windows compatibility in `log_server_test.py` (#293)

* catch `TypeError` in `remote.__del__`

* `log_server_test.py` windows compatibility
上级 6abe4f69
...@@ -152,6 +152,8 @@ def remote_class(*args, **kwargs): ...@@ -152,6 +152,8 @@ def remote_class(*args, **kwargs):
pass pass
except zmq.error.ZMQError: except zmq.error.ZMQError:
pass pass
except TypeError:
pass
def send_file(self, socket): def send_file(self, socket):
try: try:
......
...@@ -100,13 +100,15 @@ class TestLogServer(unittest.TestCase): ...@@ -100,13 +100,15 @@ class TestLogServer(unittest.TestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
log_content = json.loads(r.text).get('log') log_content = json.loads(r.text).get('log')
self.assertIsNotNone(log_content) self.assertIsNotNone(log_content)
log_content = log_content.replace('\r\n', '\n')
self.assertIn(log_content, outputs) self.assertIn(log_content, outputs)
# Test download # Test download
download_url = "http://{}/download-log".format(log_server_addr) download_url = "http://{}/download-log".format(log_server_addr)
r = requests.get(download_url, params={'job_id': job_id}) r = requests.get(download_url, params={'job_id': job_id})
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
self.assertIn(r.text, outputs) log_content = r.text.replace('\r\n', '\n')
self.assertIn(log_content, outputs)
disconnect() disconnect()
worker.exit() worker.exit()
...@@ -121,10 +123,10 @@ class TestLogServer(unittest.TestCase): ...@@ -121,10 +123,10 @@ class TestLogServer(unittest.TestCase):
th.start() th.start()
time.sleep(1) time.sleep(1)
# start the cluster monitor # start the cluster monitor
monitor_file = __file__.replace('tests/log_server_test.pyc', monitor_file = __file__.replace(
'monitor.py') os.path.join('tests', 'log_server_test.pyc'), 'monitor.py')
monitor_file = monitor_file.replace('tests/log_server_test.py', monitor_file = monitor_file.replace(
'monitor.py') os.path.join('tests', 'log_server_test.py'), 'monitor.py')
command = [ command = [
sys.executable, monitor_file, "--monitor_port", sys.executable, monitor_file, "--monitor_port",
str(monitor_port), "--address", "localhost:" + str(master_port) str(monitor_port), "--address", "localhost:" + str(master_port)
...@@ -160,13 +162,15 @@ class TestLogServer(unittest.TestCase): ...@@ -160,13 +162,15 @@ class TestLogServer(unittest.TestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
log_content = json.loads(r.text).get('log') log_content = json.loads(r.text).get('log')
self.assertIsNotNone(log_content) self.assertIsNotNone(log_content)
log_content = log_content.replace('\r\n', '\n')
self.assertIn(log_content, outputs) self.assertIn(log_content, outputs)
# Test download # Test download
download_url = job.get('download_url') download_url = job.get('download_url')
r = requests.get(download_url) r = requests.get(download_url)
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
self.assertIn(r.text, outputs) log_content = r.text.replace('\r\n', '\n')
self.assertIn(log_content, outputs)
# Clean context # Clean context
monitor_proc.kill() monitor_proc.kill()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册