+
    DfjbG                     8   R t ^ RIHt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IHt ^ RIHt ^ RIHt ^RIHt ^R	IHt ^R
IHt ^RIHtH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* R R lt+ ! R R]4      t, ! R R]4      t- ! R R]4      t.R# )z$
Tests for L{twisted.logger._json}.
)BytesIOStringIO)IOAnyListOptionalSequencecast)implementer)BrokenMethodImplementation)verifyObject)Failure)TestCase)extractField)formatEvent)globalLogPublisher)ILogObserverLogEvent)eventAsJSONeventFromJSONeventsFromJSONLogFilejsonFileLogObserverlog)LogLevel)Logger)LogPublisherc                <    V ^8  d   QhR\         R\        R\        /# )   testCase	savedJSONreturn)r   str)formats   "?/usr/lib/python3/dist-packages/twisted/logger/test/test_json.py__annotate__r$   !   s!      ( s s     c                t    V P                  V\        4       V P                  VP                  R4      ^ 4       V# )a  
Assert a few things about the result of L{eventAsJSON}, then return it.

@param testCase: The L{TestCase} with which to perform the assertions.
@param savedJSON: The result of L{eventAsJSON}.

@return: C{savedJSON}

@raise AssertionError: If any of the preconditions fail.

)assertIsInstancer!   assertEqualcount)r   r   s   &&r#   savedJSONInvariantsr+   !   s3     i-.2r%   c                      a  ] tR t^1t 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# )SaveLoadTestsz*
Tests for loading and saving log events.
c                &   < V ^8  d   QhRS[ RS[/# )r   eventr    )r   r!   )r"   __classdict__s   "r#   r$   SaveLoadTests.__annotate__6   s     	= 	=H 	= 	=r%   c                ,    \        V \        V4      4      # )zv
Serialize some an events, assert some things about it, and return the
JSON.

@param event: An event.

@return: JSON.
)r+   r   )selfr/   s   &&r#   savedEventJSONSaveLoadTests.savedEventJSON6   s     #4U);<<r%   c                   < V ^8  d   QhRR/# r   r    N )r"   r0   s   "r#   r$   r1   A   s     E ET Er%   c                Z    V P                  \        V P                  / 4      4      / 4       R# )zH
Saving and loading an empty dictionary results in an empty dictionary.
Nr)   r   r4   r3   s   &r#   test_simpleSaveLoad!SaveLoadTests.test_simpleSaveLoadA   s$     	t':':2'>?Dr%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1   G   s     

 

t 

r%   c           
     j    V P                  \        V P                  ^^RR/4      4      R^RR/4       R# )z
Saving and loading a dictionary with some simple values in it results
in those same simple values in the output; according to JSON's rules,
though, all dictionary keys must be L{str} and any non-L{str}
keys will be converted.
341Nr:   r;   s   &r#   test_saveLoadSaveLoadTests.test_saveLoadG   s:     	$--q!S#.>?@!S#	
r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1   S   s     
 
 
r%   c                ~    V P                  \        V P                  R^R\        4       /4      4      R^RRR//4       R# )z`
Saving and loading an object which cannot be represented in JSON will
result in a placeholder.
rB   r@   unpersistableTNr)   r   r4   objectr;   s   &r#   test_saveUnPersistable$SaveLoadTests.test_saveUnPersistableS   sA    
 	$--sAsFH.EFG!S?D12	
r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1   ]   s     
 
4 
r%   c                ~    V P                  \        V P                  RRR\        4       /4      4      RRRRR//4       R# )z4
Non-ASCII keys and values can be saved and loaded.
u   ሴu   䌡r@   rG   TNrH   r;   s   &r#   test_saveNonASCIISaveLoadTests.test_saveNonASCII]   sA     	$--x3.QRSx&=>	
r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1   f   s     
 
 
r%   c           	         R\        \        ^4      4      /pVP                  RR/4       V P                  \	        V P                  V4      4      R\        \        ^4      4      P                  R4      /4       R# )z`
Any L{bytes} objects will be saved as if they are latin-1 so they can
be faithfully re-loaded.
hellos   skippedokaycharmapN)bytesrangeupdater)   r   r4   decode)r3   
inputEvents   & r#   test_saveBytesSaveLoadTests.test_saveBytesf   si    
 uU3Z01
 	:v./$--j9:eE#J'..y9:	
r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1   u   s     A A$ Ar%   c                     ! R R4      pRRRV! ^4      /p\        V P                  V4      4      pV P                  \        V4      R4       R# )z
Saving and loading an object which cannot be represented in JSON, but
has a string representation which I{can} be saved as JSON, will result
in the same string formatting; any extractable fields will retain their
data types.
c                   D   a  ] tR t^}t o V 3R lR ltV 3R lR ltRtV tR# )@SaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprablec                $   < V ^8  d   QhRS[ RR/# )r   valuer    N)rI   )r"   r0   s   "r#   r$   MSaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprable.__annotate__~   s     # #f # #r%   c                    Wn         R # Nra   )r3   ra   s   &&r#   __init__ISaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprable.__init__~   s    "
r%   c                    < V ^8  d   QhRS[ /# )r   r    r!   )r"   r0   s   "r#   r$   rb      s     " "# "r%   c                    R # )reprabler8   r;   s   &r#   __repr__ISaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprable.__repr__   s    !r%   re   N)__name__
__module____qualname____firstlineno__rf   rl   __static_attributes____classdictcell__r0   s   @r#   Reprabler_   }   s     # #" "r%   ru   
log_formatz{object} {object.value}rI   z
reprable 7N)r   r4   r)   r   )r3   ru   rY   outputEvents   &   r#    test_saveUnPersistableThenFormat.SaveLoadTests.test_saveUnPersistableThenFormatu   sL    	" 	" #$=xRSU
#D$7$7
$CD[1<@r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1      s     H Ht Hr%   c                    ! R R4      p\        RV! 4       R7      p\        V P                  V4      4      pV P                  \	        RV4      R4       V P                  \        \        RV4       V P                  \        \        RV4       R# )	z[
L{extractField} can extract fields from an object that's been saved and
loaded from JSON.
c                   2   a  ] tR t^t o V 3R lR ltRtV tR# )8SaveLoadTests.test_extractingFieldsPostLoad.<locals>.Objc                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   ESaveLoadTests.test_extractingFieldsPostLoad.<locals>.Obj.__annotate__   s     ! !$ !r%   c                    R V n         R# )Y  Nre   r;   s   &r#   rf   ASaveLoadTests.test_extractingFieldsPostLoad.<locals>.Obj.__init__   s	     
r%   re   N)rn   ro   rp   rq   rf   rr   rs   rt   s   @r#   Objr}      s     ! !r%   r   z{object.value})rv   rI   zobject.valuer   rI   N)dictr   r4   r)   r   assertRaisesKeyError)r3   r   rY   loadedEvents   &   r#   test_extractingFieldsPostLoad+SaveLoadTests.test_extractingFieldsPostLoad   ss    	! 	! %5ceD
#D$7$7
$CDnkBCH
 	(L(KH(L(JGr%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1      s     : : :r%   c                   . p\        \        \        VP                  4      R7      p ^^ ,           V P                  \        V4      ^4       \        V P                  V^ ,          4      4      R,          pV P                  V\
        4       V P                  VP                  \        4      4       V P                  VP                  4       \        4       R#   \         d     \        4       pTP                  RT4        Li ; i)zT
Round-tripping a failure through L{eventAsJSON} preserves its class and
structure.
observerza message about failurelog_failureN)r   r	   r   appendZeroDivisionErrorr   failurer)   lenr   r4   r(   
assertTruecheckgetTracebackr!   )r3   eventsr   floadeds   &    r#   test_failureStructurePreserved,SaveLoadTests.test_failureStructurePreserved   s    
 "$d<?@	6E 	Va(t226!9=>}Mfg.%678f113S9 ! 	6	AKK115	6s   	C 'C>=C>c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1      s     ? ?D ?r%   c                    \        \        P                  R7      p\        V P	                  V4      4      pV P                  VR,          \        P                  4       R# )zW
It's important that the C{log_level} key remain a
L{constantly.NamedConstant} object.
	log_levelr   N)r   r   warnr   r4   assertIs)r3   rY   r   s   &  r#   test_saveLoadLevel SaveLoadTests.test_saveLoadLevel   s>    
 HMM2
#D$7$7
$CDk+.>r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r1      s     	< 	<4 	<r%   c                T    \        R4      pV P                  V\        RR7      4       R# )z
If a saved bit of JSON (let's say, from a future version of Twisted)
were to persist a different log_level, it will resolve as None.
zZ{"log_level": {"name": "other", "__class_uuid__": "02E59486-F24D-46AD-8224-3ACDF2A5732A"}}Nr   )r   r)   r   )r3   r   s   & r#   test_saveLoadUnknownLevel'SaveLoadTests.test_saveLoadUnknownLevel   s+    
 $I
 	dT&:;r%   r8   N)rn   ro   rp   rq   __doc__r4   r<   rC   rJ   rN   rZ   rx   r   r   r   r   rr   rs   rt   s   @r#   r-   r-   1   s~     	= 	=E E

 


 

 

 
A A&H H(: :$? ?	< 	<r%   r-   c                      a  ] tR t^t o RtV 3R lR ltRV 3R lR l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# )FileLogObserverTestsz#
Tests for L{jsonFileLogObserver}.
c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   !FileLogObserverTests.__annotate__   s     
 
 
r%   c                    \        4       ;_uu_ 4       p\        V4      p \        \        V4       RRR4       R#   \         d   pT P                  T4        Rp?L+Rp?ii ; i  + '       g   i     R# ; i)zP
A L{FileLogObserver} returned by L{jsonFileLogObserver} is an
L{ILogObserver}.
N)r   r   r   r   r   fail)r3   
fileHandler   es   &   r#   test_interface#FileLogObserverTests.test_interface   sV    
 ZZ:*:6H\84 Z . 		!	 ZZs,   A#:A AA#A  A##A4	c                $   < V ^8  d   QhRS[ RR/# )r   recordSeparatorr    Nri   )r"   r0   s   "r#   r$   r      s     V V V Vr%   c                    \        4       ;_uu_ 4       p\        W!4      p\        ^R7      pV! V4       V P                  VP	                  4       V R24       RRR4       R#   + '       g   i     R# ; i)z
Asserts that an observer created by L{jsonFileLogObserver} with the
given arguments writes events serialized as JSON text, using the given
record separator.

@param recordSeparator: C{recordSeparator} argument to
    L{jsonFileLogObserver}
xz	{"x": 1}
N)r   r   r   r)   getvalue)r3   r   r   r   r/   s   &&   r#   assertObserverWritesJSON-FileLogObserverTests.assertObserverWritesJSON   sT     ZZ:*:GH1IEUOZ0026G|4TU	 ZZZs   AA  A1	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r      s     ( ($ (r%   c                &    V P                  4        R# )z
A L{FileLogObserver} created by L{jsonFileLogObserver} writes events
serialzed as JSON text to a file when it observes events.
By default, the record separator is C{"\x1e"}.
Nr   r;   s   &r#   (test_observeWritesDefaultRecordSeparator=FileLogObserverTests.test_observeWritesDefaultRecordSeparator   s     	%%'r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r      s     : : :r%   c                *    V P                  RR7       R# )z
A L{FileLogObserver} created by L{jsonFileLogObserver} writes events
serialzed as JSON text to a file when it observes events.
This test sets the record separator to C{""}.
 r   Nr   r;   s   &r#   &test_observeWritesEmptyRecordSeparator;FileLogObserverTests.test_observeWritesEmptyRecordSeparator   s     	%%b%9r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r      s     " " "r%   c                  a  \        4       p\        4       p. pVP                  \        \        VP
                  4      4       VP                  \        V4      4       \        VR7      p ^^ ,           \        VP                  4       4      p\        \        V4      4      pR V 3R llpV! V4       V! V4       R#   \         d    TP                  R4        Lfi ; i)z
A L{FileLogObserver} created by L{jsonFileLogObserver} writes failures
serialized as JSON text to a file when it observes events.
r   zfailed as expectedc                >    V ^8  d   QhR\         \        ,          RR/# )r   	logEventsr    N)r   r   )r"   s   "r#   r$   AFileLogObserverTests.test_failureFormatting.<locals>.__annotate__  s     
	 
	8H#5 
	$ 
	r%   c                 l  < SP                  \        V 4      ^4       V w  pSP                  RV4       VR,          pSP                  V\        4       VP                  4       pSP                  VP                  P                  P                  P                  R4      \        P                  R4      4       R# )   r   coN)r)   r   assertInr(   r   getTracebackObjecttb_framef_codeco_filenamerstrip__file__)r   failureEventfailureObjecttracebackObjectr3   s   &   r#   checkEvents@FileLogObserverTests.test_failureFormatting.<locals>.checkEvents  s    S^Q/&N\MM-6(7M!!-9+>>@O((//;;BB4H%r%   N)r   r   addObserverr	   r   r   r   r   BaseExceptionr   r   listr   )r3   io	publisherloggedloggerreaderdeserializedr   s   f       r#   test_failureFormatting+FileLogObserverTests.test_failureFormatting   s    
 Z N	!#d<?@1"56+	1E "++-(1&9:
	 
	 	FL!%  	1NN/0	1s   (	B9 9CCr8   N))rn   ro   rp   rq   r   r   r   r   r   r   rr   rs   rt   s   @r#   r   r      s>     
 
V V( (: :" "r%   r   c                   6  a  ] tR tRt o RtV 3R lR ltV 3R lR ltR#V 3R lR	 l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# )$LogFileReaderTestsi  z%
Tests for L{eventsFromJSONLogFile}.
c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   LogFileReaderTests.__annotate__  s     
1 
1t 
1r%   c                   a  . S n         \        \        4      R  V 3R ll4       pVS n        \        P
                  ! V4       R# )c                (    V ^8  d   QhR\         RR/# )r   r/   r    N)r   )r"   s   "r#   r$   .LogFileReaderTests.setUp.<locals>.__annotate__  s     	/ 	/H 	/ 	/r%   c                    < V R ,          \         P                  8X  d'   RV 9   d   SP                  P                  V 4       R# R# R# )log_namespacerecordN)jsonLog	namespaceerrorEventsr   )r/   r3   s   &r#   r   *LogFileReaderTests.setUp.<locals>.observer  s;    _%):)::x5?P  ''. @Q:r%   N)r   r
   r   logObserverr   r   )r3   r   s   f r#   setUpLogFileReaderTests.setUp  s:    +-	\	"	/ 
#	/ $&&x0r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   &  s     < <$ <r%   c                F    \         P                  ! V P                  4       R # rd   )r   removeObserverr   r;   s   &r#   tearDownLogFileReaderTests.tearDown&  s    ))$*:*:;r%   Nc                P   < V ^8  d   QhRS[ S[,          RS[S[,          RS[RR/# )r   inFiler   
bufferSizer    N)r   r   r   r!   int)r"   r0   s   "r#   r$   r   )  s;     7 737 "#7 	7
 
7r%   c                    \        \        WV4      4      pV P                  \        V4      R^/4       V P                  \        V4      R^/4       V P	                  \
        \        V4       R# )aD  
Test that L{eventsFromJSONLogFile} reads two pre-defined events from a
file: C{{"x": 1}} and C{{"y": 2}}.

@param inFile: C{inFile} argument to L{eventsFromJSONLogFile}
@param recordSeparator: C{recordSeparator} argument to
    L{eventsFromJSONLogFile}
@param bufferSize: C{bufferSize} argument to L{eventsFromJSONLogFile}
r   yN)iterr   r)   nextr   StopIteration)r3   r   r   r   r   s   &&&& r#   _readEventsLogFileReaderTests._readEvents)  sX     +FZPQfQx0fQx0-v6r%   c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   >  s     7 7 7r%   c                    \        R4      ;_uu_ 4       pV P                  V4       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)zw
L{eventsFromJSONLogFile} reads events from a file and automatically
detects use of C{"\x1e"} as the record separator.
{"x": 1}
{"y": 2}
Nr   r  r)   r   r   r3   r   s   & r#   &test_readEventsAutoWithRecordSeparator9LogFileReaderTests.test_readEventsAutoWithRecordSeparator>  sJ    
 788JZ(S!1!12A6 9888   7AA&	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   G  s     7 7 7r%   c                    \        R4      ;_uu_ 4       pV P                  V4       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)zs
L{eventsFromJSONLogFile} reads events from a file and automatically
detects use of C{""} as the record separator.
z{"x": 1}
{"y": 2}
Nr	  r
  s   & r#   'test_readEventsAutoEmptyRecordSeparator:LogFileReaderTests.test_readEventsAutoEmptyRecordSeparatorG  sJ    
 /00JZ(S!1!12A6 1000r  c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   P  s     7 7 7r%   c                    \        R4      ;_uu_ 4       pV P                  VRR7       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)zc
L{eventsFromJSONLogFile} reads events from a file and is told to use
a specific record separator.
z{"x": 1}
{"y": 2}
r   Nr	  r
  s   & r#   &test_readEventsExplicitRecordSeparator9LogFileReaderTests.test_readEventsExplicitRecordSeparatorP  sO     788JZ@S!1!12A6 9888   9AA(	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   Z  s     7 7d 7r%   c                    \        R4      ;_uu_ 4       pV P                  V^R7       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)z=
L{eventsFromJSONLogFile} handles buffering a partial event.
r  r   Nr	  r
  s   & r#   test_readEventsPartialBuffer/LogFileReaderTests.test_readEventsPartialBufferZ  sO     788JZA6S!1!12A6 9888r  c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   c  s     H HD Hr%   c                   \        R4      ;_uu_ 4       p\        \        V4      4      pV P                  \	        V4      R^/4       V P                  \        \        V4       V P                  \        V P                  4      ^4       V P                  V P                  ^ ,          R,          R4       V P                  V P                  ^ ,          R,          R4       RRR4       R#   + '       g   i     R# ; i)z6
If the JSON text for a record is truncated, skip it.
z{"x": 1{"y": 2}
r   rv   z0Unable to read truncated JSON record: {record!r}r   s   {"x": 1N	r   r  r   r)   r  r   r  r   r   r3   r   r   s   &  r#   test_readTruncated%LogFileReaderTests.test_readTruncatedc  s     455/
;<FT&\C84mT6: S!1!12A6  #L1B T--a0:JG 6555   CC$$C5	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r   u  s     7 7$ 7r%   c                H   \        R4      ;_uu_ 4       p\        \        V4      4      pV P                  \	        V4      RR/4       V P                  \        \        V4       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)zK
If the file being read from vends L{str}, strings decode from JSON
as-is.
u   {"currency": "€"}
currency   €Nr  r   s   &  r#   test_readUnicode#LogFileReaderTests.test_readUnicodeu  sw     455/
;<FT&\J+ABmT6:S!1!12A6 6555   A2BB!	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     7 7D 7r%   c                H   \        R4      ;_uu_ 4       p\        \        V4      4      pV P                  \	        V4      RR/4       V P                  \        \        V4       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)zP
If the file being read from vends L{bytes}, strings decode from JSON as
UTF-8.
s   {"currency": "€"}
r&  r'  N	r   r  r   r)   r  r   r  r   r   r   s   &  r#   test_readUTF8Bytes%LogFileReaderTests.test_readUTF8Bytes  sy     :;;z/
;<F T&\J+ABmT6:S!1!12A6 <;;;r*  c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     7 7T 7r%   c           	     L   \        R4      ;_uu_ 4       p\        \        V^R7      4      pV P                  \	        V4      RR/4       V P                  \        \        V4       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)z
If the JSON text for a record is truncated in the middle of a two-byte
Unicode codepoint, we don't want to see a codec exception and the
stream is read properly when the additional data arrives.
s   {"x": "€"}
r  r   r'  Nr-  r   s   &  r#   test_readTruncatedUTF8Bytes.LogFileReaderTests.test_readTruncatedUTF8Bytes  sx     344
/
qIJFT&\C?;mT6:S!1!12A6 5444s   A4BB#	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     T T4 Tr%   c                   \        R4      ;_uu_ 4       p\        \        V4      4      pV P                  \	        V4      R^/4       V P                  \        \        V4       V P                  \        V P                  4      ^4       V P                  V P                  ^ ,          R,          R4       V P                  V P                  ^ ,          R,          R4       RRR4       R#   + '       g   i     R# ; i)zP
If the JSON text for a record contains invalid UTF-8 text, ignore that
record.
s   {"x": ""}
{"y": 2}
r   rv   z2Unable to decode UTF-8 for JSON record: {record!r}r   s   {"x": ""}
Nr-  r   s   &  r#   test_readInvalidUTF8Bytes,LogFileReaderTests.test_readInvalidUTF8Bytes  s     ABBj/
;<FT&\C84mT6: S!1!12A6  #L1D T--a0:<RS CBBBr#  c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     J Jd Jr%   c                   \        R4      ;_uu_ 4       p\        \        V4      4      pV P                  \	        V4      R^/4       V P                  \        \        V4       V P                  \        V P                  4      ^4       V P                  V P                  ^ ,          R,          R4       V P                  V P                  ^ ,          R,          R4       RRR4       R#   + '       g   i     R# ; i)z4
If the JSON text for a record is invalid, skip it.
z{"x": }
{"y": 2}
r   rv   &Unable to read JSON record: {record!r}r   s   {"x": }
Nr  r   s   &  r#   test_readInvalidJSON'LogFileReaderTests.test_readInvalidJSON  s     677:/
;<FT&\C84mT6: S!1!12A6  #L18 T--a0:LI 8777r#  c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     U Ud Ur%   c                   \        R4      ;_uu_ 4       p\        V4      pV P                  \        \        V4       V P                  \        V P                  4      ^4       V P                  V P                  ^ ,          R,          R4       V P                  V P                  ^ ,          R,          R4       RRR4       R#   + '       g   i     R# ; i)z9
Multiple events without a record separator are skipped.
z{"x": 1}
{"y": 2}
rv   r:  r   s   {"x": 1}
{"y": 2}
N)r   r   r   r  r  r)   r   r   r   s   &  r#   test_readUnseparated'LogFileReaderTests.test_readUnseparated  s     344
*:6FmT6: S!1!12A6  #L18 T--a0:<ST 5444s   B B>>C	c                   < V ^8  d   QhRR/# r7   r8   )r"   r0   s   "r#   r$   r     s     7 7 7r%   c                \   \        ^R7      p\        4       ;_uu_ 4       p\        V4      pV! V4       VP                  ^ 4       \	        V4      pV P                  \        V4      V34       V P                  \        V P                  4      ^ 4       RRR4       R#   + '       g   i     R# ; i)z
Data written by a L{FileLogObserver} returned by L{jsonFileLogObserver}
and read by L{eventsFromJSONLogFile} is reconstructed properly.
r   N)	r   r   r   seekr   r)   tupler   r   )r3   r/   r   r   r   s   &    r#   test_roundTrip!LogFileReaderTests.test_roundTrip  sz    
 q	ZZ:*:6HUOOOA*:6FU6]UH5S!1!12A6 ZZZs   A1BB+	)r   r   )Ni   )rn   ro   rp   rq   r   r   r   r  r  r  r  r  r!  r(  r.  r2  r6  r;  r?  rE  rr   rs   rt   s   @r#   r   r     s     
1 
1< <7 7*7 77 77 77 7H H$7 77 77 7T T(J J$U U"7 7r%   r   N)/r   r   r   r   typingr   r   r   r   r   r	   zope.interfacer
   zope.interface.exceptionsr   zope.interface.verifyr   twisted.python.failurer   twisted.trial.unittestr   _flattenr   _formatr   _globalr   _interfacesr   r   _jsonr   r   r   r   r   r   _levelsr   _loggerr   	_observerr   r+   r-   r   r   r8   r%   r#   <module>rU     sv    ! : : & @ . * + # ! ( 0    $ O<H O<dO"8 O"dP7 P7r%   