From abd2ee774c41dce5341479e660286faec95a8120 Mon Sep 17 00:00:00 2001 From: joo Date: Mon, 22 Aug 2016 18:20:16 +0100 Subject: [PATCH] Add thread timeout detection to test_connection. --- tests/test_connection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index e59b1f0..29d2759 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -10,12 +10,12 @@ from future.utils import raise_ import unittest import threading import logging -import random import socket import json import sys VERSIONS = sorted(SUPPORTED_MINECRAFT_VERSIONS.items(), key=lambda i: i[1]) +THREAD_TIMEOUT_S = 5 class _ConnectTest(unittest.TestCase): @@ -47,7 +47,9 @@ class _ConnectTest(unittest.TestCase): # Wait for all threads to exit. for thread in server_thread, client_thread: if thread.is_alive(): - thread.join() + thread.join(THREAD_TIMEOUT_S) + if thread.is_alive(): + self.fail('Thread "%s" timed out.' % thread.name) def _test_connect_client(self, client, cond): def handle_packet(packet):