def prepare_for_testing(self, ports_to_forward, test_app_bundle_id, layout_test_directory):
    if (not self.listening_socket):
        self.listening_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.listening_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.listening_socket.bind(('127.0.0.1', 0))
    if hasattr(self.platform_device, 'prepare_for_testing'):
        self.platform_device.prepare_for_testing(ports_to_forward=(ports_to_forward + [self.listening_port()]), test_app_bundle_id=test_app_bundle_id, layout_test_directory=layout_test_directory)
def prepare_for_testing(self, ports_to_forward, test_app_bundle_id, layout_test_directory):
    if (not self.listening_socket):
        self.listening_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.listening_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.listening_socket.bind(('127.0.0.1', 0))
    if hasattr(self.platform_device, 'prepare_for_testing'):
        self.platform_device.prepare_for_testing(ports_to_forward=(ports_to_forward + [self.listening_port()]), test_app_bundle_id=test_app_bundle_id, layout_test_directory=layout_test_directory)