当前位置: 首页>>代码示例>>Python>>正文


Python printer.Printer类代码示例

本文整理汇总了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())
开发者ID:lefootballroi,项目名称:honcho,代码行数:7,代码来源:test_printer.py

示例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")
开发者ID:casio,项目名称:honcho,代码行数:37,代码来源:test_printer.py

示例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())
开发者ID:azov,项目名称:honcho,代码行数:6,代码来源:test_printer.py

示例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())
开发者ID:azov,项目名称:honcho,代码行数:6,代码来源:test_printer.py

示例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())
开发者ID:azov,项目名称:honcho,代码行数:5,代码来源:test_printer.py

示例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)
开发者ID:casio,项目名称:honcho,代码行数:6,代码来源:test_printer.py

示例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())
开发者ID:lefootballroi,项目名称:honcho,代码行数:5,代码来源:test_printer.py

示例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())
开发者ID:azov,项目名称:honcho,代码行数:6,代码来源:test_printer.py

示例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"
开发者ID:nickstenning,项目名称:honcho,代码行数:5,代码来源:test_printer.py

示例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"
开发者ID:nickstenning,项目名称:honcho,代码行数:5,代码来源:test_printer.py

示例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"
开发者ID:nickstenning,项目名称:honcho,代码行数:5,代码来源:test_printer.py

示例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")
开发者ID:casio,项目名称:honcho,代码行数:4,代码来源:test_printer.py

示例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")
开发者ID:casio,项目名称:honcho,代码行数:4,代码来源:test_printer.py

示例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")
开发者ID:casio,项目名称:honcho,代码行数:4,代码来源:test_printer.py

示例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())
开发者ID:azov,项目名称:honcho,代码行数:5,代码来源:test_printer.py


注:本文中的honcho.printer.Printer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。