+
    Dfj[                        R t ^ RIHtHtHtHtHt  ^ RIHt ] ^ RI
Ht ^ RIHtHtHt ^ RIHt ^ RIHt ^RIHtHtHtHtHtHt ^R	IHt ^R
IHt  ! R R]P>                  4      t  ! R R]P>                  4      t! ! R R]P>                  4      t" ! R R]P>                  4      t# ! R R4      t$ ! R R]%4      t& ! R R]P>                  4      t'R#   ]	 d    Rt Li ; i)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                      a  ] tR t^"t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )FormattingTestsz-
Tests for basic event formatting functions.
c                ,   < V ^8  d   QhRS[ RS[RS[/#    	logFormateventreturn)r   objectstr)format__classdict__s   "A/usr/lib/python3/dist-packages/twisted/logger/test/test_format.py__annotate__FormattingTests.__annotate__'   s"     	 	 	 	C 	    c                b    WR&   \        V4      pV P                  \        V4      \        4       V# )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typer   )selfr   r   results   &&, r"   r    FormattingTests.format'   s-     (lU#d6lC(r%   c                   < V ^8  d   QhRR/# r   r   N )r    r!   s   "r"   r#   r$   2   s      S  S$  Sr%   c           	     r   V P                  RV P                  R4      4       V P                  RV P                  R4      4       V P                  RV P                  RRR7      4       V P                  RV P                  RRR	 R
7      4       V P                  RV P                  R4      4       V P                  RV P                  R4      4       V P                  RRR7      pV P                  RV4       \        \	        R4      4      pV P                  RV,           R,           V P                  RRR7      4       R# )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                      R # )yesr/   r/   r%   r"   <lambda>2FormattingTests.test_formatEvent.<locals>.<lambda>I   s    Ur%   )
not_calledcalledu   Sánchezs   SánchezUnable to format events   Snchezs   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[[_-EU ;<KK+]  	
 	t{{3D'EF.M0JKkk.Gk<&4$w- cCi')4;;~;+QRr%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$   T   s     
 
4 
r%   c                j     ! R R4      pV P                  RV P                  RV! 4       R7      4       R# )zY
L{formatEvent} will format PEP 3101 keys containing C{.}s ending with
C{()} as methods.
c                   2   a  ] tR t^Zt o V 3R lR ltRtV tR# )0FormattingTests.test_formatMethod.<locals>.Worldc                    < V ^8  d   QhRS[ /# r   r   r   )r    r!   s   "r"   r#   =FormattingTests.test_formatMethod.<locals>.World.__annotate__[   s      s r%   c                    R # )worldr/   r*   s   &r"   where6FormattingTests.test_formatMethod.<locals>.World.where[   s    r%   r/   N)__name__
__module____qualname____firstlineno__rR   __static_attributes____classdictcell__r!   s   @r"   WorldrJ   Z   s      r%   r[   zhello worldzhello {what.where()})whatN)r@   r    )r*   r[   s   & r"   test_formatMethod!FormattingTests.test_formatMethodT   s1    	 	 	4;;'=EG;L	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$   b   s     
 
t 
r%   c                t     ! R R\         4      pV P                  RV P                  RV! 4       R7      4       R# )zC
L{formatEvent} will format subscripts of attributes per PEP 3101.
c                   @   a  ] tR t^gt o ]! RRR7      tV 3R ltRtV tR# )>FormattingTests.test_formatAttributeSubscript.<locals>.Examplebarqux)foobazc                <   < V ^8  d   Qh/ S[ S[S[3,          ;R&   # )r   config)r   r   )r    r!   s   "r"   r#   KFormattingTests.test_formatAttributeSubscript.<locals>.Example.__annotate__g   s     cN? r%   r/   N)	rT   rU   rV   rW   dictrh   __annotate_func__rX   rY   rZ   s   @r"   Examplerb   g   s     %)e%?F  r%   rl   zbar quxz+{example.config[foo]} {example.config[baz]})exampleN)r   r@   r    )r*   rl   s   & r"   test_formatAttributeSubscript-FormattingTests.test_formatAttributeSubscriptb   s<    
	@f 	@ 	KK=	  	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$   r   s     % %$ %r%   c                Z    \        ^^R7      p\        V4      pV P                  RV4       R# )z%
Formatting an event with no format.
)re   rc   r1   N)rj   r   r@   r*   r   r+   s   &  r"   test_formatEventNoFormat(FormattingTests.test_formatEventNoFormatr   s*     "U#V$r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$   {   s     + +T +r%   c                    \        \        4       ^^R7      p\        V4      pV P                  RV4       V P                  \	        V4      V4       R# )z*
Formatting an event with a bogus format.
)r'   re   rc   zLog format must be strN)rj   r   r   rA   rB   rr   s   &  r"   test_formatEventWeirdFormat+FormattingTests.test_formatEventWeirdFormat{   s?     aQ7U#.7d5k6*r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$      s     + +t +r%   c                    \        RR R7      p\        V4      pV P                  RV4       V P                  \        V4      V4       R# )z6
Formatting an event that's just plain out to get us.
{evil()}c                      ^^ ,          #    r/   r/   r%   r"   r7   ?FormattingTests.test_formatUnformattableEvent.<locals>.<lambda>   s    Qr%   )r'   evilr;   N)rj   r   rA   rB   rr   s   &  r"   test_formatUnformattableEvent-FormattingTests.test_formatUnformattableEvent   s;     
?U#.7d5k6*r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$      s     > >4 >r%   c           	         RRRR \        \        \        4       4      R/p\        V4      pV P	                  RV4       V P	                  RV4       V P	                  RV4       R	# )
zB
Formatting an unformattable event that has an unformattable key.
r'   r{   r   c                      ^^ ,          # r}   r/   r/   r%   r"   r7   SFormattingTests.test_formatUnformattableEventWithUnformattableKey.<locals>.<lambda>       AEr%   gurk*MESSAGE LOST: unformattable object logged:Recoverable data:Exception during formatting:N)r   r   Unformattabler   rA   rr   s   &  r"   1test_formatUnformattableEventWithUnformattableKeyAFormattingTests.test_formatUnformattableEventWithUnformattableKey   s\    
 *Mmo&

 U#BFK)624f=r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$      s     > >T >r%   c                    \        RR \        4       R7      p\        V4      pV P                  RV4       V P                  RV4       V P                  RV4       R# )D
Formatting an unformattable event that has an unformattable value.
r{   c                      ^^ ,          # r}   r/   r/   r%   r"   r7   UFormattingTests.test_formatUnformattableEventWithUnformattableValue.<locals>.<lambda>       Qr%   )r'   r   r   r   r   r   N)rj   r   r   rA   rr   s   &  r"   3test_formatUnformattableEventWithUnformattableValueCFormattingTests.test_formatUnformattableEventWithUnformattableValue   sR     !

 U#BFK)624f=r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r$      s     J JRV Jr%   c                    \        RR RR7      p\        V\        \        \	        4       4      4      pV P                  RV4       V P                  \        R4      R,           \        R4      ,           V4       R# )	r   r{   c                      ^^ ,          # r}   r/   r/   r%   r"   r7   bFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop.<locals>.<lambda>   r   r%   okay)r'   r   recoverabler   r   z = N)rj   r   r   BaseExceptionr   rA   rB   rr   s   &  r"   @test_formatUnformattableEventWithUnformattableErrorOMGWillItStopPFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop   s^     !
 *%m]_1UVBFKd=)E1DL@&Ir%   r/   N)rT   rU   rV   rW   __doc__r    rE   r]   rn   rs   rw   r   r   r   r   rX   rY   rZ   s   @r"   r   r   "   ss     	 	 S  SD
 

 
 % %+ ++ +> >> >J Jr%   r   c                      a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
RtV tR# )TimeFormattingTestsz&
Tests for time formatting functions.
c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#    TimeFormattingTests.__annotate__   s      t r%   c                    \        V 4       R # )N)r	   rQ   s   &r"   setUpTimeFormattingTests.setUp   s
    Tr%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r      s     .
 .
$ .
r%   c                   a  \         f   \        R4      hR V 3R llpV! RRR4       V! RRR	4       V! R
RR4       V! RRR4       R# )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.c                V    V ^8  d   QhR\         R\        \         ,          R\         RR/# )r   nameexpectedDSTexpectedSTDr   N)r   r   )r    s   "r"   r#   JTimeFormattingTests.test_formatTimeWithDefaultFormat.<locals>.__annotate__   s6     
	D 
	D
	D$,SM
	D@C
	D
	Dr%   c                    < \        V 4       \        R4      pSP                  \        V4      V4       V'       d)   \        R4      pSP                  \        V4      V4       R# R# )  N)	r   r~          r   r   r   r   r   )	i        r   r   r         r~   )r   r
   r@   r   )r   r   r   localSTDlocalDSTr*   s   &&&  r"   testForTimeZoneMTimeFormattingTests.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   s   f r"    test_formatTimeWithDefaultFormat4TimeFormattingTests.test_formatTimeWithDefaultFormat   sn    
 =WXX
	D 
	D 	&	
 	&&&	
 	(&&	
 	&	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r      s     = =4 =r%   c                v    V P                  \        R4      R4       V P                  \        RRR7      R4       R# )z<
If C{when} argument is L{None}, we get the default output.
N-!)defaultr@   r   rQ   s   &r"   test_formatTimeWithNoTime-TimeFormattingTests.test_formatTimeWithNoTime   s0     	D)3/D#6<r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r      s     K KT Kr%   c                    \        R4      pV P                  \        VRR7      R4       V P                  \        VRRR7      R4       R# )zB
If C{timeFormat} argument is L{None}, we get the default output.
N
timeFormatr   r   )r   r   	i  	         (   /   r~   i  r
   r@   r   r*   ts   & r"   test_formatTimeWithNoFormat/TimeFormattingTests.test_formatTimeWithNoFormat   s?     89A$7=A$DcJr%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r     s     G G Gr%   c                V    \        R4      pV P                  \        VRR7      R4       R# )z"
Alternate time format in output.
z%Y/%Wr   z2013/38Nr   r   r   s   & r"   &test_formatTimeWithAlternateTimeFormat:TimeFormattingTests.test_formatTimeWithAlternateTimeFormat  s&     89A':IFr%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r     s     O O Or%   c                @    V P                  \        RRR7      R4       R# )z 
"%f" supported in time format.
g?x.Az%fr   234560Nr   rQ   s   &r"   test_formatTimePercentF+TimeFormattingTests.test_formatTimePercentF  s     	MdCXNr%   r/   N)rT   rU   rV   rW   r   r   r   r   r   r   r   rX   rY   rZ   s   @r"   r   r      sM      .
 .
`= =K KG GO Or%   r   c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )ClassicLogFormattingTestsi  z8
Tests for classic text log event formatting functions.
c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   &ClassicLogFormattingTests.__annotate__  s     
 
 
r%   c                    \         f   \        R4      h\        V 4       \        R4       \	        R4      p\        RVR7      pV P                  \        V4      R4       R# )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   XYZZYr'   log_timez%2013-09-24T11:40:47+0000 [-#-] XYZZY
r   )r   r   r	   r   r
   rj   r@   r   )r*   r   r   s   &  r"   test_formatTimeDefault0ClassicLogFormattingTests.test_formatTimeDefault  sT     =WXXTh89!4'.7	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   '       
 
t 
r%   c                d    R R lp\        RRR7      pV P                  \        W!R7      R4       R# )	zK
Time is first field.  Custom formatting function is an optional
argument.
c                F    V ^8  d   QhR\         \        ,          R\        /# )r   r   r   )r   floatr   )r    s   "r"   r#   EClassicLogFormattingTests.test_formatTimeCustom.<locals>.__annotate__-  s     	 	(5/ 	c 	r%   c                     R V  R 2# )__r/   )r   s   &r"   r   CClassicLogFormattingTests.test_formatTimeCustom.<locals>.formatTime-  s    s":r%   r   i90  r   )r   z__12345__ [-#-] XYZZY
Nrj   r@   r   )r*   r   r   s   &  r"   test_formatTimeCustom/ClassicLogFormattingTests.test_formatTimeCustom'  s.    	 %8'E(	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   6  s     
 
d 
r%   c                V    \        RRR7      pV P                  \        V4      R4       R# )z*
Namespace is first part of second field.
r   my.namespace)r'   log_namespacez- [my.namespace#-] XYZZY
Nr   r*   r   s   & r"   test_formatNamespace.ClassicLogFormattingTests.test_formatNamespace6  s)     ~F'.+	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   @  s     
 
$ 
r%   c                r    \        R\        P                  R7      pV P                  \	        V4      R4       R# )z'
Level is second part of second field.
r   )r'   	log_levelz- [-#warn] XYZZY
Nrj   r   warnr@   r   r   s   & r"   test_formatLevel*ClassicLogFormattingTests.test_formatLevel@  s-     8==A'.#	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   J       
 
4 
r%   c                V    \        RRR7      pV P                  \        V4      R4       R# )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                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   T  r   r%   c                v    \        RR\        P                  RR7      pV P                  \	        V4      R4       R# )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     (mm%	
 	'.&	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   c  s     
 
 
r%   c                f    \        R\        4       R7      pV P                  \        V4      R4       R# )r  r   r  z- [UNFORMATTABLE] XYZZY
N)rj   r   r@   r   r   s   & r"   test_formatSystemUnformattable8ClassicLogFormattingTests.test_formatSystemUnformattablec  s+     MOD'.'	
r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   m  r  r%   c                V    \        RRR7      pV P                  \        V4      R4       R# )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                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   w  s     @ @T @r%   c                T    \        RR7      pV P                  \        V4      R4       R# )z
No format string.
r  )r  Nrj   r(   r   r   s   & r"   test_formatNoFormat-ClassicLogFormattingTests.test_formatNoFormatw  s!     1%8$?r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r   ~  s     @ @ @r%   c                V    \        RRR7      pV P                  \        V4      R4       R# )z
Empty format string.
r1   r  r  Nr  r   s   & r"   test_formatEmptyFormat0ClassicLogFormattingTests.test_formatEmptyFormat~  s$     u-1%8$?r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   r     s     
 
D 
r%   c                T    \        RR7      pV P                  \        V4      R4       R# )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_formatFormatMultiLine4ClassicLogFormattingTests.test_formatFormatMultiLine  s(      FG'.C	
r%   r/   N)rT   rU   rV   rW   r   r   r   r   r  r  r  r  r  r   r$  r(  rX   rY   rZ   s   @r"   r   r     s|     
 
&
 

 

 

 

 

 

 
@ @@ @
 
r%   r   c                   6   a  ] tR tRt o RtV 3R lR ltRtV tR# )FormatFieldTestsi  z#
Tests for format field functions.
c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   FormatFieldTests.__annotate__  s     
 
T 
r%   c           
         V P                  \        R\        RR R7      4      R4       V P                  \        R\        R R7      4      R	4       R
# )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                      R # )mayber/   r/   r%   r"   r7   6FormatFieldTests.test_formatWithCall.<locals>.<lambda>  s    7r%   )rP   callmezHello, earth. maybe.zHello, {repr()!r}.c                      R # rB   r/   r/   r%   r"   r7   r2    s    6r%   r5  zHello, 'repr'.N)r@   r   rj   rQ   s   &r"   test_formatWithCall$FormatFieldTests.test_formatWithCall  sO     	-7?; #	
 	/>1JK	
r%   r/   N)rT   rU   rV   rW   r   r6  rX   rY   rZ   s   @r"   r+  r+    s     
 
r%   r+  c                   6   a  ] tR tRt o RtV 3R lR ltRtV tR# )r   i  z6
An object that raises an exception from C{__repr__}.
c                    < V ^8  d   QhRS[ /# rL   rM   )r    r!   s   "r"   r#   Unformattable.__annotate__  s      # r%   c                &    \        ^^ ,          4      # r}   rM   rQ   s   &r"   __repr__Unformattable.__repr__  s    1q5zr%   r/   N)rT   rU   rV   rW   r   r<  rX   rY   rZ   s   @r"   r   r     s      r%   r   c                       ] tR tRtRtRtR# )CapturedErrori  z+
A captured error for use in format tests.
r/   N)rT   rU   rV   rW   r   rX   r/   r%   r"   r?  r?    s    r%   r?  c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR # )!EventAsTextTestsi  z]
Tests for L{eventAsText}, all of which ensure that the
returned type is UTF-8 decoded text.
c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   EventAsTextTests.__annotate__  s     ? ? ?r%   c                     \        R4      h  \          d    \        4       p Mi ; iRR/pYR&   \        TRRR7      pT P                  \	        TP                  4       4      T4       T P                  RT4       R# )	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   rA   r   getTracebackr*   fr   	eventTexts   &   r"   test_eventWithTraceback(EventAsTextTests.test_eventWithTraceback  su    	 677 		A	 ()EF mER	c!..*+Y72I>    %%c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     9 9D 9r%   c                     \        R4      h  \          d    \        4       p Mi ; iRR/pYR&   \        TRRR7      pT P                  \	        TP                  4       4      T4       T P                  RT4       R# )	z]
An event with an empty C{log_format} key appends a traceback from
the accompanying failure.
rE  r'   r1   rG  TFrH  NrK  rM  s   &   r"   "test_formatEmptyEventWithTraceback3EventAsTextTests.test_formatEmptyEventWithTraceback  sr    
	 677 		A	', mER	c!..*+Y7,i8rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     9 9t 9r%   c                (    \        R4      h  \          d    \        4       p Mi ; iRRRR /pYR&   \        TRRR	7      pT P                  T\        4       T P                  \	        TP                  4       4      T4       T P                  RT4       R
# )z_
An event with an unformattable value in the C{log_format} key still
has a traceback appended.
rE  r'   r{   r   c                      ^^ ,          # r}   r/   r/   r%   r"   r7   HEventAsTextTests.test_formatUnformattableWithTraceback.<locals>.<lambda>  r   r%   rG  TFrH  N)r?  r   r   assertIsInstancer   rA   rL  rM  s   &   r"   %test_formatUnformattableWithTraceback6EventAsTextTests.test_formatUnformattableWithTraceback  s    
	 677 		A	 *M
  !mER	i-c!..*+Y7,i8rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     9 9D 9r%   c           	     |    \        R4      h  \          d    \        4       p Mi ; iRRRR \        \        \	        4       4      R/pYR&   \        TRR	R
7      pT P                  T\        4       T P                  RT4       T P                  \        TP                  4       4      T4       T P                  RT4       R# )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.
rE  r'   r{   r   c                      ^^ ,          # r}   r/   r/   r%   r"   r7   MEventAsTextTests.test_formatUnformattableErrorWithTraceback.<locals>.<lambda>  r   r%   r   rG  TFrH  zMESSAGE LOSTN)	r?  r   r   r   r   r   r[  rA   rL  rM  s   &   r"   *test_formatUnformattableErrorWithTraceback;EventAsTextTests.test_formatUnformattableErrorWithTraceback  s    	 677 		A	 *Mmo&

  !mER	i-ni0c!..*+Y7,i8rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     	L 	L 	Lr%   c                    RR/p\        4       VR&   \        VRRR7      pV P                  V\        4       V P	                  RV4       R# )	zS
If a traceback cannot be appended, a message indicating this is true
is appended.
r'   r1   rG  TFrH  z'(UNABLE TO OBTAIN TRACEBACK FROM EVENT)N)r   r   r[  r   rA   r*   r   rO  s   &  r"   &test_formatEventUnformattableTraceback7EventAsTextTests.test_formatEventUnformattableTraceback  sG    
 (,%xmER	i-?Kr%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     ? ?T ?r%   c                z    RR/p\        VRRR7      pV P                  V\        4       V P                  RV4       R# )zI
An event with no C{log_failure} key will not have a traceback appended.
r'   rF  TFrH  N)r   r[  r   rA   rf  s   &  r"   test_formatEventNonCritical,EventAsTextTests.test_formatEventNonCritical  s<     ()EFER	i-2I>r%   c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     . .t .r%   c                     \        R4      h  \          d    \        4       p Mi ; iRR/pYR&   \        TRRR7      pT P                  RT4       T P                  RT4       R	# )
zE
An exception message with multibyte characters is properly handled.
u   €r'   rF  rG  TFrH  	TracebackNr?  r   r   rA   rM  s   &   r"   test_formatTracebackMultibyte.EventAsTextTests.test_formatTracebackMultibyte  sg    	&& 		A	 ()EF mER	eY'k9-rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC  *  s     T Td Tr%   c                     \        R4      h  \          d    \        4       p Mi ; iRR/pYR&   \        TRRR7      pT P                  RT4       T P                  R	T4       R
# )zR
An error raised attempting to decode the UTF still produces a
valid log message.
s
   t e s t r'   rF  rG  TFrH  ro  z.CapturedError(b"\xff\xfet\x00e\x00s\x00t\x00")Nrp  rM  s   &   r"   ,test_formatTracebackHandlesUTF8DecodeFailure=EventAsTextTests.test_formatTracebackHandlesUTF8DecodeFailure*  si    
	 ?@@ 		A	 ()EF mER	k9-GSrR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC  ;  s     
 
D 
r%   c                     \        R4      h  \          d    \        4       p Mi ; i\        R4      pRRRRRT/pYR&   \        TRRR	R
7      pT P	                  TR4       R# )zY
If includeSystem is specified as the only option no timestamp or
traceback are printed.
rE  r'   ABCDr	  fake_systemr   rG  FTrI  includeTracebackrJ  z[fake_system] ABCDNr   r?  r   r
   r   r@   r*   rN  r   r   rO  s   &    r"   test_eventAsTextSystemOnly+EventAsTextTests.test_eventAsTextSystemOnly;  s    
	 677 		A	 89&-

  !m""	
	 	 	
rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC  W  s      
  
t  
r%   c                   \         f   \        R4      h\        V 4       \        R4        \	        R4      h  \         d    \        4       p Mi ; i\        R4      pRRRRR	T/pYR
&   \        TRRRR7      pT P                  TR4       R# )zY
If includeTimestamp is specified as the only option no system or
traceback are printed.
Nr   r   rE  r'   ry  r	  rz  r   rG  TFr{  z2013-09-24T11:40:47+0000 ABCDr   )	r   r   r	   r   r?  r   r
   r   r@   r~  s   &    r"   test_eventAsTextTimestampOnly.EventAsTextTests.test_eventAsTextTimestampOnlyW  s    
 =WXXTh	 677 		A	 89&-

  !m!"	
	 	+	
s   6 AAc                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC  y  s     
 
t 
r%   c                     \        R4      h  \          d    \        4       p Mi ; i\        R4      pRRRT/pYR&   \        TRRRR7      pT P	                  TR	4       R
# )zD
If includeSystem is specified with a missing system [-#-]
is used.
rE  r'   ry  r   rG  FTr{  z
[-#-] ABCDNr   r}  r~  s   &    r"   test_eventAsTextSystemMissing.EventAsTextTests.test_eventAsTextSystemMissingy  s}    
	 677 		A	 89&
  !m""	
	 		
rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     
 
 
r%   c                     \        R4      h  \          d    \        4       p Mi ; i\        R4      pRRRTR\        P                  RR/pYR&   \        TR	R	R
R7      pT P                  TR4       R# )zh
If includeSystem is specified with a missing system but
namespace and level are present they are used.
rE  r'   ry  r   r   r   testrG  FTr{  z[test#info] ABCDNr   r?  r   r
   r   infor   r@   r~  s   &    r"   .test_eventAsTextSystemMissingNamespaceAndLevel?EventAsTextTests.test_eventAsTextSystemMissingNamespaceAndLevel  s    
	 677 		A	 89&V	
  !m""	
	 	!	
rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     
 
 
r%   c                     \        R4      h  \          d    \        4       p Mi ; i\        R4      pRRRTR\        P                  /pYR&   \        TRRRR	7      pT P                  TR
4       R# )z^
If includeSystem is specified with a missing system but
level is present, level is included.
rE  r'   ry  r   r   rG  FTr{  z[-#info] ABCDNr   r  r~  s   &    r"   &test_eventAsTextSystemMissingLevelOnly7EventAsTextTests.test_eventAsTextSystemMissingLevelOnly  s    
	 677 		A	 89&

  !m""	
	 		
rR  c                   < V ^8  d   QhRR/# r.   r/   )r    r!   s   "r"   r#   rC    s     @ @T @r%   c                    R R lpV P                  \        \        4      V! R\        R7      4       V P                  \        \        4      V! R\        R7      4       V P                  RV! R\        R7      4       R# )zH
C{eventAsText} can handle formats that have classes or types as input.
c                <    V ^8  d   QhR\         R\        R\         /# r   )r   r   )r    s   "r"   r#   BEventAsTextTests.test_eventAsTextTypeAsInput.<locals>.__annotate__  s!     	 	s 	S 	S 	r%   c                 (    \        R V /VCRRRR7      # )r'   Fr{  )r   )r   r   s   &,r"   getText=EventAsTextTests.test_eventAsTextTypeAsInput.<locals>.getText  s%    y2E2!&!&#	 r%   z{c})cr   z{c.__name__}N)r@   r   intRuntimeError)r*   r  s   & r"   test_eventAsTextTypeAsInput,EventAsTextTests.test_eventAsTextTypeAsInput  sW    
	 	S75C#89\*GE\,JK# >?r%   r/   N)rT   rU   rV   rW   r   rP  rU  r\  rb  rg  rk  rq  ru  r  r  r  r  r  r  rX   rY   rZ   s   @r"   rA  rA    s     
? ?9 99 9(9 9.	L 	L? ?. .T T"
 
8 
  
D
 
6
 
:
 
8@ @r%   rA  )(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?  rA  r/   r%   r"   <module>r     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