From fb07a5112a8284a533ffb8ec1242d5e23b3eafd4 Mon Sep 17 00:00:00 2001 From: Zsin Skri Date: Wed, 17 Jul 2019 13:16:01 +0200 Subject: [PATCH] bpd tests: terminate server upon connection failure --- test/test_player.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/test_player.py b/test/test_player.py index 37d0b6640..77ebef7d4 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -310,21 +310,23 @@ class BPDTestHelper(unittest.TestCase, TestHelper): ], assigned_port)) server.start() - # Wait until the socket is connected: - for _ in range(20): - if assigned_port.value != 0: - # read which port has been assigned by the OS - port = assigned_port.value - break - time.sleep(0.01) - else: - raise RuntimeError('Timed out waiting for the BPD server') - - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((host, port)) - - sock2 = None try: + # Wait until the socket is connected: + for _ in range(20): + if assigned_port.value != 0: + # read which port has been assigned by the OS + port = assigned_port.value + break + time.sleep(0.01) + else: + raise RuntimeError( + 'Timed out waiting for the BPD server to start' + ) + + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host, port)) + + sock2 = None if second_client: sock2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock2.connect((host, port))