Ϫf-fddlmZddlmZ ddlZeZddlmZGddeZ y#e$rdZYwxYw))Failure)TestCaseN)syslogcdeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZy)SyslogObserverTestszS Tests for L{SyslogObserver} which sends Twisted log events to the syslog. Nz(syslog is not supported on this platformc|jtjd|j|jtjd|jtjd|_y)Nopenlogrr)patchrSyslogObserverr observerselfs A/usr/lib/python3/dist-packages/twisted/python/test/test_syslog.pysetUpzSyslogObserverTests.setUpsI 6(()T\\B 6(((DKK@--.CD c&|||f|_g|_yN) logOpenedevents)rprefixoptionsfacilitys rr zSyslogObserverTests.openlogs '84 rc>|jj||fyr)rappend)rrmessages rrzSyslogObserverTests.syslog#s GW-.rcz|jjdddd|j|jgy)zm L{SyslogObserver.emit} ignores events with an empty value for the C{'message'} key. F-risErrorsystemN)r emit assertEqualrr s rtest_emitWithoutMessagez+SyslogObserverTests.test_emitWithoutMessage&s1 resKL b)rc|jjdddtjd|j |j tjdfgy) L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the syslog priority, if that key is present in the event dictionary. z hello, worldFr)rr r!syslogPriority[-] hello, worldN)r r" stdsyslog LOG_DEBUGr#rr s rtest_emitCustomPriorityz+SyslogObserverTests.test_emitCustomPriority.sR , "+"5"5     (;(;=O'P&QRrc |jjdddttdd|j |j t jdfgy)zd L{SyslogObserver.emit} uses C{LOG_ALERT} if the event represents an error. r'Trfoo)rr r!failurer)N)r r"r Exceptionr#rr* LOG_ALERTr s rtest_emitErrorPriorityz*SyslogObserverTests.test_emitErrorPriority=sV ,"9U#34     (;(;=O'P&QRrc |jjdddtjt t dd|j |jtjdfgy)z L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} key if it is specified even if the event dictionary represents an error. r'Trbar)rr r!r(r/r)N)r r"r* LOG_NOTICErr0r#rr s r%test_emitCustomPriorityOverridesErrorz9SyslogObserverTests.test_emitCustomPriorityOverridesErrorLs_ ,"+"6"6"9U#34     (<(<>P'Q&RSrc|jjdddtjd|j |j tj tjzdfgy)r&r'Fr)rr r!syslogFacilityr)N)r r"r*LOG_CRONr#rLOG_INFOr s rtest_emitCustomFacilityz+SyslogObserverTests.test_emitCustomFacility\s` , "+"4"4     KK9-- 0B0BBDVWX rc|jjdddd|j|jtj dfgy)zt L{SyslogObserver.emit} uses the value of the C{'system'} key to prefix the logged message. r'FnonDefaultSystemrz[nonDefaultSystem] hello, worldNr r"r#rr*r:r s rtest_emitCustomSystemz)SyslogObserverTests.test_emitCustomSystemmsL , ,    KK9--/PQR rc|jjdddd|j|jtj dfgy)z L{SyslogObserver.emit} logs the value of the C{'message'} key of the event dictionary it is passed to the syslog. r'Frrr)Nr>r s rtest_emitMessagez$SyslogObserverTests.test_emitMessage}sE )es K   (:(:r s rtest_emitMultilineMessagez-SyslogObserverTests.test_emitMultilineMessagesU *u L   KK  , /)2D2Dm1T U rc|jjdddd|j|jtj dftj dfgy)zw Trailing empty lines of a multiline message are omitted from the messages sent to the syslog. )zhello, world FrrrCrDNr>r s r!test_emitStripsTrailingEmptyLinesz5SyslogObserverTests.test_emitStripsTrailingEmptyLinessU .5C P   KK  , /)2D2Dm1T U r)__name__ __module__ __qualname____doc__rr*skiprr rr$r,r2r6r;r?rArErGrrrrrsZF9E /* S ST  " R    rr) twisted.python.failurertwisted.trial.unittestrr _stdsyslogr*twisted.python ImportErrorrrrrrRsC++&I%N (N Is &00