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)))
评论列表
文章目录