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_write_multiline(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("one\ntwo\nthree\n"))
expect = "12:42:00 | one\n12:42:00 | two\n12:42:00 | three\n"
assert out.string() == expect
def test_write(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("monkeys\n"))
assert out.string() == "12:42:00 | monkeys\n"
def test_write_with_set_width(self):
out = FakeOutput()
p = Printer(output=out, width=6)
p.write(fake_message("giraffe\n"))
assert out.string() == "12:42:00 | giraffe\n"
def test_write_with_name_and_set_width(self):
out = FakeOutput()
p = Printer(output=out, width=6)
p.write(fake_message("narcissist\n", name="oop"))
assert out.string() == "12:42:00 oop | narcissist\n"
def test_write_without_prefix_and_colour_tty(self):
out = FakeTTY()
p = Printer(output=out, prefix=False, colour=False)
p.write(fake_message("paranoid android\n", name="foo", colour="31"))
assert out.string() == "paranoid android\n"
def test_write_no_newline(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("monkeys"))
assert out.string() == "12:42:00 | monkeys\n"
def test_write_wrong_type(self):
out = FakeOutput()
p = Printer(output=out)
with pytest.raises(RuntimeError):
p.write(fake_message("monkeys\n", type="error"))
def test_write_with_colour_non_tty(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("conflate\n", name="foo", colour="31"))
assert out.string() == "12:42:00 foo | conflate\n"
def test_write_without_prefix_non_tty(self):
out = FakeOutput()
p = Printer(output=out, prefix=False)
p.write(fake_message("paranoid android\n", name="foo", colour="31"))
assert out.string() == "paranoid android\n"
concurrency = _parse_concurrency(args.concurrency)
env = _read_env(args.app_root, args.env)
quiet = _parse_quiet(args.quiet)
port = _choose_port(args, env)
if args.processes:
processes = compat.OrderedDict()
for name in args.processes:
try:
processes[name] = procfile.processes[name]
except KeyError:
raise CommandError("Process type '{0}' does not exist in Procfile".format(name))
else:
processes = procfile.processes
manager = Manager(Printer(sys.stdout,
colour=(not args.no_colour),
prefix=(not args.no_prefix)))
for p in environ.expand_processes(processes,
concurrency=concurrency,
env=env,
quiet=quiet,
port=port):
e = os.environ.copy()
e.update(p.env)
manager.add_process(p.name, p.cmd, quiet=p.quiet, env=e)
manager.loop()
sys.exit(manager.returncode)