39 from queue
import Empty, Queue
42 OUTPUT_ENCODING = sys.getfilesystemencoding()
60 subprocess_args =
dict(bufsize=0,
61 stdout=subprocess.PIPE,
62 stderr=subprocess.PIPE,
63 stdin=subprocess.PIPE,
66 startupinfo = subprocess.STARTUPINFO()
69 startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
71 startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
72 subprocess_args[
'startupinfo'] = startupinfo
73 subprocess_args[
'env'] =
dict(os.environ, PYTHONIOENCODING=
'UTF-8')
75 subprocess_args[
'preexec_fn'] = os.setsid
76 subprocess_args[
'shell'] =
True
77 self.
_process_process = subprocess.Popen(command, **subprocess_args)
86 self.
_port_port = port
95 return self.
_process_process.returncode
98 return self.
_process_process.poll()
is None
103 def kill(self, force=False, killer_pid=None):
109 if IS_WINDOWS
and not self.
_kill_called_kill_called
and self.
_port_port
is not None:
119 if self.
_port_port
is None:
127 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
128 sock.connect((host, self.
_port_port))
129 sock.send(bytes(data, OUTPUT_ENCODING))
142 self.
_send_socket_send_socket(
'do_not_pause_on_failure')
157 os.kill(pid, signal.SIGINT)
172 self.
_thread_thread.daemon =
True
176 for line
in iter(out.readline, b
''):
177 self.
_queue_queue.put(line)
181 my_queue_rng = range(self.
_queue_queue.qsize())
182 for _
in my_queue_rng:
184 result += self.
_queue_queue.get_nowait()
def _signal_kill_with_listener_server(self)
def kill(self, force=False, killer_pid=None)
def _send_socket(self, data)
def pause_on_failure(self, pause)
def run_command(self, command)
def __init__(self, stream)
def _enqueue_output(self, out)
def run(*tests, **options)
Programmatic entry point for running tests.