def server(host, port): # definition of your server @pytest.fixture(autouse=True, scope="session") def start_server(): p = multiprocessing.Process(target=server, args=(host, port)) p.start() yield p.terminate()