Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ctor_name(self):
proc = Process('echo 123', name='foo')
assert proc.name == 'foo'
def test_cwd_passed_along(self):
proc = Process('echo 123', cwd='fake-dir')
proc._child_ctor = FakePopen
proc.run(self.q)
assert proc._child.kwargs['cwd'] == 'fake-dir'
def test_ctor_colour(self):
proc = Process('echo 123', colour='red')
assert proc.colour == 'red'
def test_output_receives_lines(self):
def _ctor(*args, **kwargs):
popen = FakePopen(*args, **kwargs)
popen.stdout = FakeOutput(lines=[b"hello\n", b"world\n"])
return popen
proc = Process('echo 123')
proc._child_ctor = _ctor
proc.run(self.q)
assert self.q.got_message(b"hello\n")
assert self.q.got_message(b"world\n")
def test_output_does_not_receive_lines_when_quiet(self):
def _ctor(*args, **kwargs):
popen = FakePopen(*args, **kwargs)
popen.stdout = FakeOutput(lines=[b"hello\n", b"world\n"])
return popen
proc = Process('echo 123', quiet=True)
proc._child_ctor = _ctor
proc.run(self.q)
assert not self.q.got_message(b"hello\n")
assert not self.q.got_message(b"world\n")
def test_output_receives_stop(self):
proc = Process('echo 123')
proc._child_ctor = FakePopen
proc.run(self.q)
msg = self.q.messages[-1]
assert msg.type == 'stop'
def test_message_contains_name(self):
proc = Process('echo 123', name="barry")
proc._child_ctor = FakePopen
proc.run(self.q)
msg = self.q.messages[0]
assert msg.name == "barry"
def test_ctor_quiet(self):
proc = Process('echo 123', quiet=True)
assert proc.quiet
# TODO: move back into make install
os.system("python -m django_zero install")
os.system("yarn install")
os.system("python -m django_zero manage migrate")
# Run the webpack assets builder
os.system("python -m django_zero webpack")
target = "127.0.0.1", get_free_port()
print("Target:", *target)
events = multiprocessing.Queue()
server_command = "python -m django_zero manage runserver {0}:{1}".format(*target)
print("Command:", server_command)
server = Process(server_command, name="server")
server_process = multiprocessing.Process(name="server", target=server.run, args=(events, True))
try:
server_process.start()
exit = False
pid = None
while 1:
try:
msg = events.get(timeout=0.1)
except Empty:
if exit:
break
else:
# print(msg)
if msg.type == "start":
def __init__(self, printer=None):
self.events = multiprocessing.Queue()
self.returncode = None
self._colours = get_colours()
self._env = Env()
self._printer = printer if printer is not None else Printer(sys.stdout)
self._printer.width = len(SYSTEM_PRINTER_NAME)
self._process_ctor = Process
self._processes = {}
self._terminating = False