def test_connectionLost_does_not_log_reason_when_lost_cleanly(self): listener = PostgresListenerService() with TwistedLoggerFixture() as logger: listener.connectionLost(Failure(error.ConnectionDone())) self.assertThat(logger.errors, HasLength(0))
def test__connectionLost_logs_reason(self): listener = PostgresListenerService() failure = Failure(factory.make_exception("Treason!")) with TwistedLoggerFixture() as logger: listener.connectionLost(failure) self.assertThat( logger.output, DocTestMatches("""\ Connection lost. Traceback (most recent call last):... Failure: maastesting.factory.TestException#...: Treason! """))