ó
    Ö›‘hô[  ã                   ó¾  • S r SSKJrJrJrJrJr   SSKJr  \  SSK
Jr  SSKJrJrJr  SSKJr  SSKJr  S	S
KJrJrJrJrJrJr  S	SKJr  S	SKJr   " S S\R>                  5      r  " S S\R>                  5      r! " S S\R>                  5      r" " S S\R>                  5      r# " S S5      r$ " S S\%5      r& " S S\R>                  5      r'g! \	 a    Sr NÁf = f)z+
Test cases for L{twisted.logger._format}.
é    )ÚAnyÚAnyStrÚDictÚOptionalÚcast)ÚtzsetN)ÚFailure)ÚaddTZCleanupÚmktimeÚsetTZ)Úunittest)ÚSkipTesté   )ÚeventAsTextÚformatEventÚformatEventAsClassicLogTextÚ
formatTimeÚformatUnformattableEventÚformatWithCall)ÚLogEvent)ÚLogLevelc                   óˆ   • \ rS rSrSrS\S\S\4S jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)ÚFormattingTestsé"   z-
Tests for basic event formatting functions.
Ú	logFormatÚeventÚreturnc                 ób   • XS'   [        U5      nU R                  [        U5      [        5        U$ )z¶
Create a Twisted log event dictionary from C{event} with the given
C{logFormat} format string, format it with L{formatEvent}, ensure that
its type is L{str}, and return its result.
Ú
log_format)r   ÚassertIsÚtypeÚstr)Úselfr   r   Úresults       ÚcC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/logger/test/test_format.pyÚformatÚFormattingTests.format'   s-   € ð (ˆlÑÜ˜UÓ#ˆØ�‰”d˜6“l¤CÔ(Øˆó    Nc           	      óH  • U R                  SU R                  S5      5        U R                  SU R                  S5      5        U R                  SU R                  SSS95        U R                  SU R                  SSS	 S
95        U R                  SU R                  S5      5        U R                  SU R                  S5      5        U R                  SSS9nU R                  SU5        [        [	        S5      5      nU R                  SU-   S-   U R                  SSS95        g)a  
L{formatEvent} will format an event according to several rules:

    - A string with no formatting instructions will be passed straight
      through.

    - PEP 3101 strings will be formatted using the keys and values of
      the event as named fields.

    - PEP 3101 keys ending with C{()} will be treated as instructions
      to call that key (which ought to be a callable) before
      formatting.

L{formatEvent} will always return L{str}, and if given bytes, will
always treat its format string as UTF-8 encoded.
Ú r(   Úabcz{x})Úxzno, yes.z{not_called}, {called()}.Únoc                  ó   • g)NÚyes© r0   r(   r%   Ú<lambda>Ú2FormattingTests.test_formatEvent.<locals>.<lambda>I   s   € ÈUr(   )Ú
not_calledÚcalledu   SÃ¡nchezs   SÃ¡nchezúUnable to format events   Sánchezs   S{a!s}nchezó   á)ÚazSb'\xe1'nchezÚSÚnchezs   S{a!r}nchezN)ÚassertEqualr&   ÚassertInr"   Úrepr)r#   ÚmaybeResultÚxe1s      r%   Útest_formatEventÚ FormattingTests.test_formatEvent2   s  € ð" 	×Ñ˜˜TŸ[™[¨Ó-Ô.Ø×Ñ˜˜TŸ[™[¨›_Ô-Ø×Ñ˜ §¡¨E°U Ð ;Ô<Ø×ÑØØ�K‰KØ+¸Á]ð ð ô	
ð 	×Ñ˜ t§{¡{Ð3DÓ'EÔFØ�‰Ð.°·±¸MÓ0JÔKØ—k‘k .°G�kÐ<ˆØ�‰Ð&¨Ô4ä”$�w“-Ó ˆØ�‰�c˜C‘i 'Ñ)¨4¯;©;°~È¨;Ð+QÕRr(   c                 ób   •  " S S5      nU R                  SU R                  SU" 5       S95        g)zY
L{formatEvent} will format PEP 3101 keys containing C{.}s ending with
C{()} as methods.
c                   ó"   • \ rS rSrS\4S jrSrg)Ú0FormattingTests.test_formatMethod.<locals>.WorldéZ   r   c                 ó   • g)NÚworldr0   ©r#   s    r%   ÚwhereÚ6FormattingTests.test_formatMethod.<locals>.World.where[   s   € Ør(   r0   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r"   rH   Ú__static_attributes__r0   r(   r%   ÚWorldrC   Z   s   † ð˜s÷ r(   rO   zhello worldzhello {what.where()})ÚwhatN)r:   r&   )r#   rO   s     r%   Útest_formatMethodÚ!FormattingTests.test_formatMethodT   s1   € ÷	ñ 	ð 	×ÑØ˜4Ÿ;™;Ð'=ÁEÃG˜;ÐLõ	
r(   c                 ól   •  " S S[         5      nU R                  SU R                  SU" 5       S95        g)zC
L{formatEvent} will format subscripts of attributes per PEP 3101.
c                   ó8   • \ rS rSr% \" SSS9r\\\4   \S'   Sr	g)Ú>FormattingTests.test_formatAttributeSubscript.<locals>.Exampleég   ÚbarÚqux)ÚfooÚbazÚconfigr0   N)
rJ   rK   rL   rM   Údictr[   r   r"   Ú__annotations__rN   r0   r(   r%   ÚExamplerU   g   s   ‡ Ù%)¨e¸Ñ%?ˆF�D˜˜c˜‘NÖ?r(   r^   zbar quxz+{example.config[foo]} {example.config[baz]})ÚexampleN)Úobjectr:   r&   )r#   r^   s     r%   Útest_formatAttributeSubscriptÚ-FormattingTests.test_formatAttributeSubscriptb   s<   € ô
	@”fô 	@ð 	×ÑØØ�K‰KØ=Ù›	ð ð õ	
r(   c                 óR   • [        SSS9n[        U5      nU R                  SU5        g)z%
Formatting an event with no format.
é   r   )rY   rW   r*   N)r\   r   r:   ©r#   r   r$   s      r%   Útest_formatEventNoFormatÚ(FormattingTests.test_formatEventNoFormatr   s*   € ô ˜ Ñ"ˆÜ˜UÓ#ˆà×Ñ˜˜VÕ$r(   c                 óš   • [        [        5       SSS9n[        U5      nU R                  SU5        U R                  [	        U5      U5        g)z*
Formatting an event with a bogus format.
rd   r   )r   rY   rW   zLog format must be strN)r\   r`   r   r;   r<   re   s      r%   Útest_formatEventWeirdFormatÚ+FormattingTests.test_formatEventWeirdFormat{   s?   € ô ¤£¨a°QÑ7ˆÜ˜UÓ#ˆà�‰Ð.°Ô7Ø�‰”d˜5“k 6Õ*r(   c                 óŠ   • [        SS S9n[        U5      nU R                  SU5        U R                  [        U5      U5        g)z6
Formatting an event that's just plain out to get us.
ú{evil()}c                  ó   • SS-  $ ©Nrd   r   r0   r0   r(   r%   r1   Ú?FormattingTests.test_formatUnformattableEvent.<locals>.<lambda>‰   s   € ¸¸Qºr(   ©r   Úevilr5   N)r\   r   r;   r<   re   s      r%   Útest_formatUnformattableEventÚ-FormattingTests.test_formatUnformattableEvent…   s;   € ô  
±Ñ?ˆÜ˜UÓ#ˆà�‰Ð.°Ô7Ø�‰”d˜5“k 6Õ*r(   c           	      óÄ   • SSSS [        [        [        5       5      S0n[        U5      nU R	                  SU5        U R	                  SU5        U R	                  SU5        g	)
zB
Formatting an unformattable event that has an unformattable key.
r   rl   rq   c                  ó   • SS-  $ rn   r0   r0   r(   r%   r1   ÚSFormattingTests.test_formatUnformattableEventWithUnformattableKey.<locals>.<lambda>•   ó   € ˜A šEr(   Úgurkú*MESSAGE LOST: unformattable object logged:úRecoverable data:úException during formatting:N)r   r"   ÚUnformattabler   r;   re   s      r%   Ú1test_formatUnformattableEventWithUnformattableKeyÚAFormattingTests.test_formatUnformattableEventWithUnformattableKey�   s\   € ð
 ˜*Ø‘MÜ””m“oÓ&¨ð
ˆô
 ˜UÓ#ˆØ�‰ÐBÀFÔKØ�‰Ð)¨6Ô2Ø�‰Ð4°fÕ=r(   c                 ó®   • [        SS [        5       S9n[        U5      nU R                  SU5        U R                  SU5        U R                  SU5        g)úD
Formatting an unformattable event that has an unformattable value.
rl   c                  ó   • SS-  $ rn   r0   r0   r(   r%   r1   ÚUFormattingTests.test_formatUnformattableEventWithUnformattableValue.<locals>.<lambda>£   ó   € ˜˜Qšr(   )r   rq   rx   ry   rz   r{   N)r\   r|   r   r;   re   s      r%   Ú3test_formatUnformattableEventWithUnformattableValueÚCFormattingTests.test_formatUnformattableEventWithUnformattableValue�   sR   € ô Ø!ÙÜ“ñ
ˆô
 ˜UÓ#ˆØ�‰ÐBÀFÔKØ�‰Ð)¨6Ô2Ø�‰Ð4°fÕ=r(   c                 óØ   • [        SS SS9n[        U[        [        [	        5       5      5      nU R                  SU5        U R                  [        S5      S-   [        S5      -   U5        g)	r€   rl   c                  ó   • SS-  $ rn   r0   r0   r(   r%   r1   ÚbFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop.<locals>.<lambda>±   rƒ   r(   Úokay)r   rq   Úrecoverablery   rŠ   z = N)r\   r   r   ÚBaseExceptionr|   r;   r<   re   s      r%   Ú@test_formatUnformattableEventWithUnformattableErrorOMGWillItStopÚPFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop«   s^   € ô Ø!ÙØñ
ˆô *¨%´´mÄ]Ã_Ó1UÓVˆØ�‰ÐBÀFÔKØ�‰”d˜=Ó)¨EÑ1´D¸³LÑ@À&ÕIr(   r0   ©r   N)rJ   rK   rL   rM   Ú__doc__r   r`   r"   r&   r?   rQ   ra   rf   ri   rr   r}   r„   rŒ   rN   r0   r(   r%   r   r   "   sQ   † ñð	 ð 	°ð 	¸Cô 	ô SôD
ô
ô %ô+ô+ô>ô>÷Jr(   r   c                   óT   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS	 jr
S
rg)ÚTimeFormattingTestséº   z&
Tests for time formatting functions.
Nc                 ó   • [        U 5        g )N)r
   rG   s    r%   ÚsetUpÚTimeFormattingTests.setUp¿   s
   € Ü�TÕr(   c                 óÀ   ^ • [         c  [        S5      eS[        S[        [           S[        SS4U 4S jjnU" SSS	5        U" S
SS5        U" SSS5        U" SSS5        g)zŒ
Default time stamp format is RFC 3339 and offset respects the timezone
as set by the standard C{TZ} environment variable and L{tzset} API.
Nú:Platform cannot change timezone; unable to verify offsets.ÚnameÚexpectedDSTÚexpectedSTDr   c                 óÄ   >• [        U 5        [        S5      nTR                  [        U5      U5        U(       a'  [        S5      nTR                  [        U5      U5        g g )N)	i×  rd   é   r   r   r   r   rœ   r   )	iÖ  é   é   r   r   r   é   éµ   rd   )r   r   r:   r   )r˜   r™   rš   ÚlocalSTDÚlocalDSTr#   s        €r%   ÚtestForTimeZoneÚMTimeFormattingTests.test_formatTimeWithDefaultFormat.<locals>.testForTimeZoneÊ   sT   ø€ ô �$ŒKäÐ>Ó?ˆHØ×ÑœZ¨Ó1°;Ô?æÜ!Ð"CÓD�Ø× Ñ ¤¨HÓ!5°{ÕCð r(   úUTC+00z2007-01-31T00:00:00+0000zEST+05EDT,M4.1.0,M10.5.0z2006-06-30T00:00:00-0400z2007-01-31T00:00:00-0500zCEST-01CEDT,M4.1.0,M10.5.0z2006-06-30T00:00:00+0200z2007-01-31T00:00:00+0100zCST+06z2007-01-31T00:00:00-0600)r   r   r"   r   )r#   r£   s   ` r%   Ú test_formatTimeWithDefaultFormatÚ4TimeFormattingTests.test_formatTimeWithDefaultFormatÂ   s�   ø€ ô
 ‰=ÜÐWÓXÐXð
	DÜð
	DÜ$,¬S¡Mð
	DÜ@Cð
	Dà÷
	Dñ 	ØØØ&ô	
ñ 	Ø&Ø&Ø&ô	
ñ 	Ø(Ø&Ø&ô	
ñ 	ØØØ&õ	
r(   c                 ón   • U R                  [        S5      S5        U R                  [        SSS9S5        g)z<
If C{when} argument is L{None}, we get the default output.
NÚ-Ú!)Údefault©r:   r   rG   s    r%   Útest_formatTimeWithNoTimeÚ-TimeFormattingTests.test_formatTimeWithNoTimeò   s0   € ð 	×Ñœ DÓ)¨3Ô/Ø×Ñœ D°#Ñ6¸Õ<r(   c                 ó„   • [        S5      nU R                  [        USS9S5        U R                  [        USSS9S5        g)zB
If C{timeFormat} argument is L{None}, we get the default output.
©	iÝ  é	   é   é   é(   é/   rd   i  éÿÿÿÿN©Ú
timeFormatr©   rª   )r¸   r«   ©r   r:   r   ©r#   Úts     r%   Útest_formatTimeWithNoFormatÚ/TimeFormattingTests.test_formatTimeWithNoFormatù   s?   € ô Ð8Ó9ˆØ×Ñœ A°$Ñ7¸Ô=Ø×Ñœ A°$ÀÑDÀcÕJr(   c                 óN   • [        S5      nU R                  [        USS9S5        g)z"
Alternate time format in output.
r°   z%Y/%Wr·   z2013/38Nr¹   rº   s     r%   Ú&test_formatTimeWithAlternateTimeFormatÚ:TimeFormattingTests.test_formatTimeWithAlternateTimeFormat  s&   € ô Ð8Ó9ˆØ×Ñœ A°'Ñ:¸IÕFr(   c                 ó8   • U R                  [        SSS9S5        g)z 
"%f" supported in time format.
g’?x€„.Az%fr·   Ú234560Nr¬   rG   s    r%   Útest_formatTimePercentFÚ+TimeFormattingTests.test_formatTimePercentF  s   € ð 	×Ñœ M¸dÑCÀXÕNr(   r0   rŽ   )rJ   rK   rL   rM   r�   r”   r¦   r­   r¼   r¿   rÃ   rN   r0   r(   r%   r‘   r‘   º   s)   † ñôô.
ô`=ôKôG÷Or(   r‘   c                   ó†   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSrg)ÚClassicLogFormattingTestsi  z8
Tests for classic text log event formatting functions.
Nc                 ó´   • [         c  [        S5      e[        U 5        [        S5        [	        S5      n[        SUS9nU R                  [        U5      S5        g)z¢
Time is first field.  Default time stamp format is RFC 3339 and offset
respects the timezone as set by the standard C{TZ} environment variable
and L{tzset} API.
Nr—   r¥   r°   ÚXYZZY©r   Úlog_timez%2013-09-24T11:40:47+0000 [-#-] XYZZY
)r   r   r
   r   r   r\   r:   r   )r#   r»   r   s      r%   Útest_formatTimeDefaultÚ0ClassicLogFormattingTests.test_formatTimeDefault  sT   € ô ‰=ÜÐWÓXÐXä�TÔÜˆhŒäÐ8Ó9ˆÜ °!Ñ4ˆØ×ÑÜ'¨Ó.Ø7õ	
r(   c                 óz   • S[         [           S[        4S jn[        SSS9nU R	                  [        X!S9S5        g	)
zK
Time is first field.  Custom formatting function is an optional
argument.
r»   r   c                 ó   • SU  S3$ )NÚ__r0   )r»   s    r%   r   ÚCClassicLogFormattingTests.test_formatTimeCustom.<locals>.formatTime-  s   € Ø˜�s˜"�:Ðr(   rÈ   i90  rÉ   )r   z__12345__ [-#-] XYZZY
N)r   Úfloatr"   r\   r:   r   )r#   r   r   s      r%   Útest_formatTimeCustomÚ/ClassicLogFormattingTests.test_formatTimeCustom'  s@   € ð	œ(¤5™/ð 	¬cô 	ô  °%Ñ8ˆØ×ÑÜ'¨ÑEØ(õ	
r(   c                 óN   • [        SSS9nU R                  [        U5      S5        g)z*
Namespace is first part of second field.
rÈ   úmy.namespace)r   Úlog_namespacez- [my.namespace#-] XYZZY
N©r\   r:   r   ©r#   r   s     r%   Útest_formatNamespaceÚ.ClassicLogFormattingTests.test_formatNamespace6  s)   € ô  °~ÑFˆØ×ÑÜ'¨Ó.Ø+õ	
r(   c                 ój   • [        S[        R                  S9nU R                  [	        U5      S5        g)z'
Level is second part of second field.
rÈ   )r   Ú	log_levelz- [-#warn] XYZZY
N©r\   r   Úwarnr:   r   rØ   s     r%   Útest_formatLevelÚ*ClassicLogFormattingTests.test_formatLevel@  s-   € ô  ´8·=±=ÑAˆØ×ÑÜ'¨Ó.Ø#õ	
r(   c                 óN   • [        SSS9nU R                  [        U5      S5        g)z
System is second field.
rÈ   úS.Y.S.T.E.M.©r   Ú
log_systemú- [S.Y.S.T.E.M.] XYZZY
Nr×   rØ   s     r%   Útest_formatSystemÚ+ClassicLogFormattingTests.test_formatSystemJ  s)   € ô  °NÑCˆØ×ÑÜ'¨Ó.Ø&õ	
r(   c                 ón   • [        SS[        R                  SS9nU R                  [	        U5      S5        g)ú2
System is not supplanted by namespace and level.
rÈ   rÕ   râ   )r   rÖ   rÜ   rä   rå   NrÝ   rØ   s     r%   Útest_formatSystemRulzÚ/ClassicLogFormattingTests.test_formatSystemRulzT  s9   € ô ØØ(Ü—m‘mØ%ñ	
ˆð 	×ÑÜ'¨Ó.Ø&õ	
r(   c                 ó^   • [        S[        5       S9nU R                  [        U5      S5        g)ré   rÈ   rã   z- [UNFORMATTABLE] XYZZY
N)r\   r|   r:   r   rØ   s     r%   Útest_formatSystemUnformattableÚ8ClassicLogFormattingTests.test_formatSystemUnformattablec  s+   € ô  ´M³OÑDˆØ×ÑÜ'¨Ó.Ø'õ	
r(   c                 óN   • [        SSS9nU R                  [        U5      S5        g)z 
Formatted event is last field.
zid:{id}Ú123©r   Úidz- [-#-] id:123
Nr×   rØ   s     r%   Útest_formatFormatÚ+ClassicLogFormattingTests.test_formatFormatm  s)   € ô  	¨eÑ4ˆØ×ÑÜ'¨Ó.Ø!õ	
r(   c                 óL   • [        SS9nU R                  [        U5      S5        g)z
No format string.
rð   )rò   N©r\   r    r   rØ   s     r%   Útest_formatNoFormatÚ-ClassicLogFormattingTests.test_formatNoFormatw  s!   € ô ˜‘ˆØ�‰Ô1°%Ó8¸$Õ?r(   c                 óN   • [        SSS9nU R                  [        U5      S5        g)z
Empty format string.
r*   rð   rñ   Nrö   rØ   s     r%   Útest_formatEmptyFormatÚ0ClassicLogFormattingTests.test_formatEmptyFormat~  s$   € ô   uÑ-ˆØ�‰Ô1°%Ó8¸$Õ?r(   c                 óL   • [        SS9nU R                  [        U5      S5        g)z?
If the formatted event has newlines, indent additional lines.
z"XYZZY
A hollow voice says:
"Plugh")r   z-- [-#-] XYZZY
	A hollow voice says:
	"Plugh"
Nr×   rØ   s     r%   Útest_formatFormatMultiLineÚ4ClassicLogFormattingTests.test_formatFormatMultiLine…  s(   € ô Ð FÑGˆØ×ÑÜ'¨Ó.ØCõ	
r(   r0   rŽ   )rJ   rK   rL   rM   r�   rË   rÒ   rÙ   rß   ræ   rê   rí   ró   r÷   rú   rý   rN   r0   r(   r%   rÆ   rÆ     s@   † ñô
ô&
ô
ô
ô
ô
ô
ô
ô@ô@÷
r(   rÆ   c                   ó"   • \ rS rSrSrSS jrSrg)ÚFormatFieldTestsi�  z#
Tests for format field functions.
Nc           
      ó–   • U R                  [        S[        SS S95      S5        U R                  [        S[        S S95      S	5        g
)zÒ
L{formatWithCall} is an extended version of L{str.format} that
will interpret a set of parentheses "C{()}" at the end of a format key
to mean that the format key ought to be I{called} rather than
stringified.
zHello, {world}. {callme()}.Úearthc                  ó   • g)NÚmayber0   r0   r(   r%   r1   Ú6FormatFieldTests.test_formatWithCall.<locals>.<lambda>Ÿ  s   € °7r(   )rF   ÚcallmezHello, earth. maybe.zHello, {repr()!r}.c                  ó   • g)Nr<   r0   r0   r(   r%   r1   r  ¤  s   € À6r(   )r<   zHello, 'repr'.N)r:   r   r\   rG   s    r%   Útest_formatWithCallÚ$FormatFieldTests.test_formatWithCall•  sO   € ð 	×ÑÜØ-Ü˜7©?Ñ;óð #ô	
ð 	×ÑÜÐ/´¹>Ñ1JÓKØõ	
r(   r0   rŽ   )rJ   rK   rL   rM   r�   r  rN   r0   r(   r%   r   r   �  s   † ñ÷
r(   r   c                   ó&   • \ rS rSrSrS\4S jrSrg)r|   i©  z6
An object that raises an exception from C{__repr__}.
r   c                 ó   • [        SS-  5      $ rn   )r"   rG   s    r%   Ú__repr__ÚUnformattable.__repr__®  s   € Ü�1�q‘5‹zÐr(   r0   N)rJ   rK   rL   rM   r�   r"   r  rN   r0   r(   r%   r|   r|   ©  s   † ñð˜#÷ r(   r|   c                   ó   • \ rS rSrSrSrg)ÚCapturedErrori²  z+
A captured error for use in format tests.
r0   N)rJ   rK   rL   rM   r�   rN   r0   r(   r%   r  r  ²  s   † ôr(   r  c                   ó¤   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)ÚEventAsTextTestsi¸  z]
Tests for L{eventAsText}, all of which ensure that the
returned type is UTF-8 decoded text.
Nc                 óì   •  [        S5      e! [          a    [        5       n Of = fSS0nXS'   [        USSS9nU R                  [	        UR                  5       5      U5        U R                  SU5        g)	zD
An event with a C{log_failure} key will have a traceback appended.
úThis is a fake errorr   úThis is a test log messageÚlog_failureTF©ÚincludeTimestampÚincludeSystemN©r  r	   r   r;   r"   ÚgetTraceback©r#   Úfr   Ú	eventTexts       r%   Útest_eventWithTracebackÚ(EventAsTextTests.test_eventWithTraceback¾  su   € ð	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úð (Ð)EÐFˆØ ˆmÑÜ ¸ÈEÑRˆ	Ø�‰”c˜!Ÿ.™.Ó*Ó+¨YÔ7Ø�‰Ð2°IÕ>ó   ‚ �$£$c                 óì   •  [        S5      e! [          a    [        5       n Of = fSS0nXS'   [        USSS9nU R                  [	        UR                  5       5      U5        U R                  SU5        g)	z]
An event with an empty C{log_format} key appends a traceback from
the accompanying failure.
r  r   r*   r  TFr  Nr  r  s       r%   Ú"test_formatEmptyEventWithTracebackÚ3EventAsTextTests.test_formatEmptyEventWithTracebackÍ  sr   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úà'¨Ð,ˆØ ˆmÑÜ ¸ÈEÑRˆ	Ø�‰”c˜!Ÿ.™.Ó*Ó+¨YÔ7Ø�‰Ð,¨iÕ8r   c                 ó  •  [        S5      e! [          a    [        5       n Of = fSS S.nXS'   [        USSS9nU R                  U[        5        U R                  [	        UR                  5       5      U5        U R                  SU5        g	)
z_
An event with an unformattable value in the C{log_format} key still
has a traceback appended.
r  rl   c                  ó   • SS-  $ rn   r0   r0   r(   r%   r1   ÚHEventAsTextTests.test_formatUnformattableWithTraceback.<locals>.<lambda>è  rw   r(   rp   r  TFr  N)r  r	   r   ÚassertIsInstancer"   r;   r  r  s       r%   Ú%test_formatUnformattableWithTracebackÚ6EventAsTextTests.test_formatUnformattableWithTracebackÜ  s‰   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úð %Ù!ñ
ˆð  !ˆmÑÜ ¸ÈEÑRˆ	Ø×Ñ˜i¬Ô-Ø�‰”c˜!Ÿ.™.Ó*Ó+¨YÔ7Ø�‰Ð,¨iÕ8r   c           	      ór  •  [        S5      e! [          a    [        5       n Of = fSSSS [        [        [	        5       5      S0nXS'   [        USS	S
9nU R                  U[        5        U R                  SU5        U R                  [        UR                  5       5      U5        U R                  SU5        g)z’
An event with an unformattable value in the C{log_format} key, that
throws an exception when __repr__ is invoked still has a traceback
appended.
r  r   rl   rq   c                  ó   • SS-  $ rn   r0   r0   r(   r%   r1   ÚMEventAsTextTests.test_formatUnformattableErrorWithTraceback.<locals>.<lambda>ý  rw   r(   rx   r  TFr  zMESSAGE LOSTN)	r  r	   r   r"   r|   r   r'  r;   r  r  s       r%   Ú*test_formatUnformattableErrorWithTracebackÚ;EventAsTextTests.test_formatUnformattableErrorWithTracebackð  s©   € ð	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úð ˜*Ø‘MÜ””m“oÓ&¨ð
ˆð
  !ˆmÑÜ ¸ÈEÑRˆ	Ø×Ñ˜i¬Ô-Ø�‰�n iÔ0Ø�‰”c˜!Ÿ.™.Ó*Ó+¨YÔ7Ø�‰Ð,¨iÕ8r   c                 óŒ   • SS0n[        5       US'   [        USSS9nU R                  U[        5        U R	                  SU5        g)	zS
If a traceback cannot be appended, a message indicating this is true
is appended.
r   r*   r  TFr  z'(UNABLE TO OBTAIN TRACEBACK FROM EVENT)N)r`   r   r'  r"   r;   ©r#   r   r  s      r%   Ú&test_formatEventUnformattableTracebackÚ7EventAsTextTests.test_formatEventUnformattableTraceback  sG   € ð
 (¨Ð,ˆÜ%›xˆˆmÑÜ ¸ÈEÑRˆ	Ø×Ñ˜i¬Ô-Ø�‰Ð?ÀÕKr(   c                 ór   • SS0n[        USSS9nU R                  U[        5        U R                  SU5        g)zI
An event with no C{log_failure} key will not have a traceback appended.
r   r  TFr  N)r   r'  r"   r;   r0  s      r%   Útest_formatEventNonCriticalÚ,EventAsTextTests.test_formatEventNonCritical  s<   € ð (Ð)EÐFˆÜ ¸ÈEÑRˆ	Ø×Ñ˜i¬Ô-Ø�‰Ð2°IÕ>r(   c                 ó¾   •  [        S5      e! [          a    [        5       n Of = fSS0nXS'   [        USSS9nU R                  SU5        U R                  SU5        g	)
zE
An exception message with multibyte characters is properly handled.
u   â‚¬r   r  r  TFr  Ú	TracebackN©r  r	   r   r;   r  s       r%   Útest_formatTracebackMultibyteÚ.EventAsTextTests.test_formatTracebackMultibyte  sg   € ð	Ü Ó&Ð&øÜó 	Ü“	ŠAð	úð (Ð)EÐFˆØ ˆmÑÜ ¸ÈEÑRˆ	Ø�‰�e˜YÔ'Ø�‰�k 9Õ-r   c                 ó¾   •  [        S5      e! [          a    [        5       n Of = fSS0nXS'   [        USSS9nU R                  SU5        U R                  S	U5        g
)zR
An error raised attempting to decode the UTF still produces a
valid log message.
s
   ÿþt e s t r   r  r  TFr  r7  z.CapturedError(b"\xff\xfet\x00e\x00s\x00t\x00")Nr8  r  s       r%   Ú,test_formatTracebackHandlesUTF8DecodeFailureÚ=EventAsTextTests.test_formatTracebackHandlesUTF8DecodeFailure*  si   € ð
	äÐ ?Ó@Ð@øÜó 	Ü“	ŠAð	úð (Ð)EÐFˆØ ˆmÑÜ ¸ÈEÑRˆ	Ø�‰�k 9Ô-Ø�‰ÐGÈÕSr   c                 ó¶   •  [        S5      e! [          a    [        5       n Of = f[        S5      nSSUS.nXS'   [        USSSS	9nU R	                  US
5        g)zY
If includeSystem is specified as the only option no timestamp or
traceback are printed.
r  r°   ÚABCDÚfake_system©r   rä   rÊ   r  FT©r  ÚincludeTracebackr  z[fake_system] ABCDN©r  r	   r   r   r:   ©r#   r  r»   r   r  s        r%   Útest_eventAsTextSystemOnlyÚ+EventAsTextTests.test_eventAsTextSystemOnly;  s|   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úô Ð8Ó9ˆà Ø'Øñ
ˆð
  !ˆmÑÜØØ"Ø"Øñ	
ˆ	ð 	×ÑØØ õ	
r   c                 ó  • [         c  [        S5      e[        U 5        [        S5         [	        S5      e! [         a    [        5       n Of = f[        S5      nSSUS.nXS	'   [        US
SSS9nU R                  US5        g)zY
If includeTimestamp is specified as the only option no system or
traceback are printed.
Nr—   r¥   r  r°   r?  r@  rA  r  TFrB  z2013-09-24T11:40:47+0000 ABCD)	r   r   r
   r   r  r	   r   r   r:   rE  s        r%   Útest_eventAsTextTimestampOnlyÚ.EventAsTextTests.test_eventAsTextTimestampOnlyW  sž   € ô
 ‰=ÜÐWÓXÐXä�TÔÜˆhŒð	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úô Ð8Ó9ˆà Ø'Øñ
ˆð
  !ˆmÑÜØØ!Ø"Øñ	
ˆ	ð 	×ÑØØ+õ	
s   ª5 µAÁAc                 ó´   •  [        S5      e! [          a    [        5       n Of = f[        S5      nSUS.nXS'   [        USSSS9nU R	                  US	5        g
)zD
If includeSystem is specified with a missing system [-#-]
is used.
r  r°   r?  rÉ   r  FTrB  z
[-#-] ABCDNrD  rE  s        r%   Útest_eventAsTextSystemMissingÚ.EventAsTextTests.test_eventAsTextSystemMissingy  sy   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úô Ð8Ó9ˆà Øñ
ˆð  !ˆmÑÜØØ"Ø"Øñ	
ˆ	ð 	×ÑØØõ	
r   c                 óÔ   •  [        S5      e! [          a    [        5       n Of = f[        S5      nSU[        R                  SS.nXS'   [        USSSS	9nU R                  US
5        g)zh
If includeSystem is specified with a missing system but
namespace and level are present they are used.
r  r°   r?  Útest)r   rÊ   rÜ   rÖ   r  FTrB  z[test#info] ABCDN©r  r	   r   r   Úinfor   r:   rE  s        r%   Ú.test_eventAsTextSystemMissingNamespaceAndLevelÚ?EventAsTextTests.test_eventAsTextSystemMissingNamespaceAndLevel”  sƒ   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úô Ð8Ó9ˆà ØÜ!Ÿ™Ø#ñ	
ˆð  !ˆmÑÜØØ"Ø"Øñ	
ˆ	ð 	×ÑØØ!õ	
r   c                 óÒ   •  [        S5      e! [          a    [        5       n Of = f[        S5      nSU[        R                  S.nXS'   [        USSSS9nU R                  US	5        g
)z^
If includeSystem is specified with a missing system but
level is present, level is included.
r  r°   r?  )r   rÊ   rÜ   r  FTrB  z[-#info] ABCDNrP  rE  s        r%   Ú&test_eventAsTextSystemMissingLevelOnlyÚ7EventAsTextTests.test_eventAsTextSystemMissingLevelOnly±  s€   € ð
	ÜÐ 6Ó7Ð7øÜó 	Ü“	ŠAð	úô Ð8Ó9ˆà ØÜ!Ÿ™ñ
ˆð
  !ˆmÑÜØØ"Ø"Øñ	
ˆ	ð 	×ÑØØõ	
r   c                 ó  • S[         S[        S[         4S jnU R                  [        [        5      U" S[        S95        U R                  [        [        5      U" S[        S95        U R                  SU" S[         S95        g	)
zH
C{eventAsText} can handle formats that have classes or types as input.
r   r   r   c                 ó"   • [        SU 0UESSSS9$ )Nr   FrB  )r   )r   r   s     r%   ÚgetTextÚ=EventAsTextTests.test_eventAsTextTypeAsInput.<locals>.getTextÒ  s%   € ÜØ˜yÐ2¨EÐ2Ø!&Ø!&Ø#ñ	ð r(   z{c})Úcr"   z{c.__name__}N)r"   r   r:   ÚintÚRuntimeError)r#   rY  s     r%   Útest_eventAsTextTypeAsInputÚ,EventAsTextTests.test_eventAsTextTypeAsInputÍ  sl   € ð
	œsð 	¬Sð 	´Sô 	ð 	×ÑœœS›¡7¨5´CÑ#8Ô9Ø×Ñœœ\Ó*©G°E¼\Ñ,JÔKØ×Ñ˜¡¨¼#Ñ >Õ?r(   r0   rŽ   )rJ   rK   rL   rM   r�   r  r"  r(  r-  r1  r4  r9  r<  rF  rI  rL  rR  rU  r^  rN   r0   r(   r%   r  r  ¸  sQ   † ñô
?ô9ô9ô(9ô.	Lô?ô.ôTô"
ô8 
ôD
ô6
ô:
÷8@r(   r  )(r�   Útypingr   r   r   r   r   Útimer   ÚImportErrorÚtwisted.python.failurer	   Ú!twisted.python.test.test_tzhelperr
   r   r   Útwisted.trialr   Útwisted.trial.unittestr   Ú_formatr   r   r   r   r   r   Ú_interfacesr   Ú_levelsr   ÚTestCaser   r‘   rÆ   r   r|   Ú	Exceptionr  r  r0   r(   r%   Ú<module>rl     sÚ   ðñ÷ 5Õ 4ðÝñ 
õ +ß IÑ IÝ "Ý +÷÷ õ #Ý ôUJ�h×'Ñ'ô UJôpRO˜(×+Ñ+ô ROôj~
 × 1Ñ 1ô ~
ôB
�x×(Ñ(ô 
÷2ñ ô�Iô ôd@�x×(Ñ(õ d@øðS ó Ø‚Eðús   ’C ÃCÃC