test_services.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
def test__protocol_logs_stderr(self):
        logger = self.useFixture(TwistedLoggerFixture())
        ifname = factory.make_name('eth')
        service = NeighbourDiscoveryService(ifname, lambda _: None)
        protocol = service.createProcessProtocol()
        reactor.spawnProcess(protocol, b"sh", (b"sh", b"-c", b"exec cat >&2"))
        protocol.transport.write(
            b"Lines written to stderr are logged\n"
            b"with a prefix, with no exceptions.\n")
        protocol.transport.closeStdin()
        yield protocol.done
        self.assertThat(logger.output, Equals(
            "observe-arp[%s]: Lines written to stderr are logged\n"
            "---\n"
            "observe-arp[%s]: with a prefix, with no exceptions."
            % (ifname, ifname)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号