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