From 99778d9ece151736ea2447a70e3fe7efd146b6c8 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 30 May 2019 12:02:47 -0400 Subject: [PATCH] bpd tests: Randomize port number This is a hacky but effective way to work around a problem when running the tests in parallel where two different test executions want to use the same port. --- test/test_player.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_player.py b/test/test_player.py index 102df1d7d..6b3e57d53 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -29,6 +29,7 @@ import time import yaml import tempfile from contextlib import contextmanager +import random from beets.util import confit, py3_path from beetsplug import bpd @@ -261,12 +262,17 @@ class BPDTestHelper(unittest.TestCase, TestHelper): self.unload_plugins() @contextmanager - def run_bpd(self, host='localhost', port=9876, password=None, + def run_bpd(self, host='localhost', port=None, password=None, do_hello=True, second_client=False): """ Runs BPD in another process, configured with the same library database as we created in the setUp method. Exposes a client that is connected to the server, and kills the server at the end. """ + # Choose a port (randomly) to avoid conflicts between parallel + # tests. + if not port: + port = 9876 + random.randint(0, 10000) + # Create a config file: config = { 'pluginpath': [py3_path(self.temp_dir)],