本文整理汇总了Python中honcho.printer.Printer类的典型用法代码示例。如果您正苦于以下问题:Python Printer类的具体用法?Python Printer怎么用?Python Printer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Printer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_defaults_multiline
def test_defaults_multiline(self):
out = FakeOutput()
p = Printer(output=out, env=FakeEnv())
p.write("one\ntwo\nthree")
expect = "12:42:00 unknown | one\n12:42:00 unknown | two\n12:42:00 unknown | three"
self.assertEqual(expect, out.last_write())
示例2: TestPrinter
class TestPrinter(object):
def setup(self):
self.out = MagicMock()
self._dt_patch = patch('honcho.printer.datetime')
self._dt = self._dt_patch.start()
self._dt.now.return_value = datetime.datetime(2012, 8, 11, 12, 42)
def teardown(self):
self._dt_patch.stop()
def test_defaults_simple(self):
self.p = Printer(output=self.out)
self.p.write("monkeys")
self.out.write.assert_called_once_with("12:42:00 unknown | monkeys")
def test_defaults_multiline(self):
self.p = Printer(output=self.out)
self.p.write("one\ntwo\nthree")
expect = "12:42:00 unknown | one\n12:42:00 unknown | two\n12:42:00 unknown | three"
self.out.write.assert_called_once_with(expect)
def test_name_simple(self):
self.p = Printer(output=self.out, name="Robert Louis Stevenson")
self.p.write("quiescent")
self.out.write.assert_called_once_with("12:42:00 Robert Louis Stevenson | quiescent")
def test_length_simple(self):
self.p = Printer(output=self.out, name="oop", width=6)
self.p.write("narcissist")
self.out.write.assert_called_once_with("12:42:00 oop | narcissist")
def test_colour_simple(self):
self.p = Printer(output=self.out, name="red", colour="31")
self.p.write("conflate")
self.out.write.assert_called_once_with("\033[31m12:42:00 red | \033[0mconflate")
示例3: test_write_with_name
def test_write_with_name(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("quiescent\n", name="Robert Louis Stevenson"))
self.assertEqual("12:42:00 Robert Louis Stevenson | quiescent\n",
out.string())
示例4: test_write_multiline
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"
self.assertEqual(expect, out.string())
示例5: test_write_no_newline
def test_write_no_newline(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("monkeys"))
self.assertEqual("12:42:00 | monkeys\n", out.string())
示例6: test_defaults_multiline
def test_defaults_multiline(self):
self.p = Printer(output=self.out)
self.p.write("one\ntwo\nthree")
expect = "12:42:00 unknown | one\n12:42:00 unknown | two\n12:42:00 unknown | three"
self.out.write.assert_called_once_with(expect)
示例7: test_length_simple
def test_length_simple(self):
out = FakeOutput()
p = Printer(output=out, name="oop", width=6, env=FakeEnv())
p.write("narcissist")
self.assertEqual("12:42:00 oop | narcissist", out.last_write())
示例8: test_write_with_colour
def test_write_with_colour(self):
out = FakeOutput()
p = Printer(output=out)
p.write(fake_message("conflate\n", name="foo", colour="31"))
self.assertEqual("\033[31m12:42:00 foo | \033[0mconflate\n",
out.string())
示例9: test_write_with_colour_tty
def test_write_with_colour_tty(self):
out = FakeTTY()
p = Printer(output=out)
p.write(fake_message("conflate\n", name="foo", colour="31"))
assert out.string() == "\033[0m\033[31m12:42:00 foo | \033[0mconflate\n"
示例10: test_write_without_prefix_non_tty
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"
示例11: test_write_without_colour_tty
def test_write_without_colour_tty(self):
out = FakeTTY()
p = Printer(output=out, prefix=True, colour=False)
p.write(fake_message("paranoid android\n", name="foo", colour="31"))
assert out.string() == "12:42:00 foo | paranoid android\n"
示例12: test_colour_simple
def test_colour_simple(self):
self.p = Printer(output=self.out, name="red", colour="31")
self.p.write("conflate")
self.out.write.assert_called_once_with("\033[31m12:42:00 red | \033[0mconflate")
示例13: test_length_simple
def test_length_simple(self):
self.p = Printer(output=self.out, name="oop", width=6)
self.p.write("narcissist")
self.out.write.assert_called_once_with("12:42:00 oop | narcissist")
示例14: test_name_simple
def test_name_simple(self):
self.p = Printer(output=self.out, name="Robert Louis Stevenson")
self.p.write("quiescent")
self.out.write.assert_called_once_with("12:42:00 Robert Louis Stevenson | quiescent")
示例15: test_write_with_set_width
def test_write_with_set_width(self):
out = FakeOutput()
p = Printer(output=out, width=6)
p.write(fake_message("giraffe\n"))
self.assertEqual("12:42:00 | giraffe\n", out.string())