+
    Dfj"                         R t ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RI	H
t
 ^RIHtHt ^RIHt ^RIHt ^R	IHt ^R
IHt ]! ]4       ! R R]4      4       t ! R R]
P.                  4      tR# )z'
Test cases for L{twisted.logger._io}.
N)ListOptional)implementer)NamedConstant)unittest)ILogObserverLogEvent)LoggingFile)LogLevel)Logger)LogPublisherc                   p   a a ] tR t^t oRt]P                  R3V3R lV 3R llltV3R lR ltRt	Vt
V ;t# )TestLoggingFilezM
L{LoggingFile} that is also an observer which captures events and messages.
Nc                @   < V ^8  d   QhRS[ RS[RS[S[,          RR/# )   loggerlevelencodingreturnN)r   r   r   str)format__classdict__s   "=/usr/lib/python3/dist-packages/twisted/logger/test/test_io.py__annotate__TestLoggingFile.__annotate__   s7     & && & 3-	&
 
&    c                F   < \         SV `  WVR 7       . V n        . V n        R# )r   r   r   N)super__init__eventsmessages)selfr   r   r   	__class__s   &&&&r   r   TestLoggingFile.__init__   s%     	hG&(#%r   c                $   < V ^8  d   QhRS[ RR/# r   eventr   Nr   )r   r   s   "r   r   r   '   s     2 2h 24 2r   c                    V P                   P                  V4       R V9   d%   V P                  P                  VR ,          4       R# R# )log_ioN)r    appendr!   )r"   r'   s   &&r   __call__TestLoggingFile.__call__'   s7    5!uMM  x1 r   )r    r!   )__name__
__module____qualname____firstlineno____doc__r
   infor   r,   __static_attributes____classdictcell____classcell__)r#   r   s   @@r   r   r      s/       (}}"&	& &2 2 2r   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
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]P4                  R*3V 3R+ lR, lltR-tV tR*# ).LoggingFileTestsz
Tests for L{LoggingFile}.
c                   < V ^8  d   QhRR/# r   r   N )r   r   s   "r   r   LoggingFileTests.__annotate__2   s     6 6t 6r   c                Z    \        4       V n        \        V P                  R7      V n        R# )z;
Create a logger for test L{LoggingFile} instances to use.
observerN)r   	publisherr   r   )r"   s   &r   setUpLoggingFileTests.setUp2   s     &dnn5r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   9   s     
 
 
r   c                l   V P                  \        V P                  4      P                  ^ 4       V P	                  V P
                  .4      pV P                  \        V4      ^4       V P                  V^ ,          R,          \        4       RpV P                  V^ ,          R,          RV,          4       R# )z 
L{LoggingFile.softspace} is 0.
categoryz(twisted.logger._io.LoggingFile.softspacemessagez#%s was deprecated in Twisted 21.2.0N)assertEqualr	   r   	softspaceflushWarningstest_softspacelenDeprecationWarning)r"   warningsShowndeprecatedClasss   &  r   rJ   LoggingFileTests.test_softspace9   s     	T[[1;;Q?**D,?,?+@A]+Q/q)*57IJD!Y'1_E	
r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   H   s     
E 
E 
Er   c                T   \        V P                  4      pV P                  \        \        VRR4       V P                  \        \        VRR4       V P                  \        \        VRR4       V P                  \        \        VRR.4       V P                  \        \        VR	R
4       R# )z/
Some L{LoggingFile} attributes are read-only.
closedTr   utf-8modernewlines
namefooN)r	   r   assertRaisesAttributeErrorsetattrr"   fs   & r   test_readOnlyAttributes(LoggingFileTests.test_readOnlyAttributesH   s     $.'1hE.'1j'J.'1fcB.'1j4&I.'1feDr   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   T   s     / / /r   c                0   \        V P                  4      pV P                  \        VP                  4       V P                  \        VP
                  4       V P                  \        VP                  4       V P                  \        VP                  4       V P                  \        VP                  4       V P                  \        VP                  4       V P                  \        VP                  4       V P                  \        VP                  4       R# )z.
Some L{LoggingFile} methods are unsupported.
N)r	   r   rZ   IOErrorreadnextreadline	readlines
xreadlinesseektelltruncater]   s   & r   test_unsupportedMethods(LoggingFileTests.test_unsupportedMethodsT   s     $'166*'166*'1::.'1;;/'1<<0'166*'166*'1::.r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   c   s     2 2D 2r   c                "   \        V P                  4      pV P                  VP                  \        P
                  4       \        V P                  \        P                  R7      pV P                  VP                  \        P                  4       R# )z/
Default level is L{LogLevel.info} if not set.
r   N)r	   r   rG   r   r
   r3   errorr]   s   & r   
test_levelLoggingFileTests.test_levelc   sV     $(--08>>:(..1r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   m   s     . .t .r   c                    \        V P                  4      pV P                  VP                  \        P
                  ! 4       4       \        V P                  RR7      pV P                  VP                  R4       R# )z=
Default encoding is C{sys.getdefaultencoding()} if not set.
rS   r   N)r	   r   rG   r   sysgetdefaultencodingr]   s   & r   test_encodingLoggingFileTests.test_encodingm   sS     $S%;%;%=>g6W-r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   w   s     & &4 &r   c                h    \        V P                  4      pV P                  VP                  R4       R# )z
Reported mode is C{"w"}.
wN)r	   r   rG   rT   r]   s   & r   	test_modeLoggingFileTests.test_modew   s&     $%r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<   ~   s     & &t &r   c                f    \        V P                  4      pV P                  VP                  4       R# )z'
The C{newlines} attribute is L{None}.
N)r	   r   assertIsNonerV   r]   s   & r   test_newlinesLoggingFileTests.test_newlines~   s$     $!**%r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     S S4 Sr   c                h    \        V P                  4      pV P                  VP                  R4       R# )z!
The C{name} attribute is fixed.
z.<LoggingFile twisted.logger.test.test_io#info>N)r	   r   rG   rX   r]   s   & r   	test_nameLoggingFileTests.test_name   s'     $!QRr   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     8 8D 8r   c                    \        V P                  4      pVP                  4        V P                  VP                  4       V P                  \        VP                  R4       R# )z'
L{LoggingFile.close} closes the file.
HelloN)r	   r   close
assertTruerR   rZ   
ValueErrorwriter]   s   & r   
test_closeLoggingFileTests.test_close   sA     $		!*aggw7r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s      D r   c                P    \        V P                  4      pVP                  4        R# )z$
L{LoggingFile.flush} does nothing.
N)r	   r   flushr]   s   & r   
test_flushLoggingFileTests.test_flush   s     $		r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     ) )T )r   c                p    \        V P                  4      pV P                  VP                  4       R4       R# )z&
L{LoggingFile.fileno} returns C{-1}.
N)r	   r   rG   filenor]   s   & r   test_filenoLoggingFileTests.test_fileno   s(     $R(r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     % %T %r   c                n    \        V P                  4      pV P                  VP                  4       4       R# )z)
L{LoggingFile.isatty} returns C{False}.
N)r	   r   assertFalseisattyr]   s   & r   test_isattyLoggingFileTests.test_isatty   s&     $$r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     
 
T 
r   c                :   V P                  4       pVP                  R4       V P                  VP                  . 4       VP                  R4       V P                  VP                  R.4       VP                  R4       V P                  VP                  . RO4       R# )z
Writing buffers correctly.
r   z	, world!
Hello, world!zIt's nice to meet you.

Indeed.Nr   zIt's nice to meet you. observedFiler   rG   r!   r]   s   & r   test_writeBuffering$LoggingFileTests.test_writeBuffering   s|     	R(	o%67	34JJ	
r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     @ @ @r   c                    V P                  RR7      pVP                  R4       V P                  VP                  R.4       R# )z
Bytes are decoded to text.
rS   rv   s   Hello, Mr. Sánchez
   Hello, Mr. SánchezNr   r]   s   & r   test_writeBytesDecoded'LoggingFileTests.test_writeBytesDecoded   s<     w/	./&=%>?r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     @ @4 @r   c                    V P                  RR7      pVP                  R4       V P                  VP                  R.4       R# )z
Unicode is unmodified.
rS   rv   u   Hello, Mr. Sánchez
r   Nr   r]   s   & r   test_writeUnicode"LoggingFileTests.test_writeUnicode   s<     w/	)*&=%>?r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     C C Cr   c                   V P                  4       pVP                  R4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          R,          \
        P                  4       V P                  \
        P                  R7      pVP                  R4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          R,          \
        P                  4       R# )z 
Log level is emitted properly.
Hello
	log_levelrp   N)r   r   rG   rK   r    r
   r3   rq   r]   s   & r   test_writeLevel LoggingFileTests.test_writeLevel   s     		QXX*![18==AHNN3		QXX*![18>>Br   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     @ @$ @r   c                    V P                  4       pVP                  R4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          R,          R4       R# )z
Log format is C{"{message}"}.
r   
log_formatz{log_io}N)r   r   rG   rK   r    r]   s   & r   test_writeFormat!LoggingFileTests.test_writeFormat   sS     		QXX*!\2J?r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     
 
$ 
r   c                :   V P                  4       pVP                  R4       V P                  VP                  . 4       VP                  R4       V P                  VP                  R.4       VP                  R4       V P                  VP                  . RO4       R# )z&
C{writelines} does not add newlines.
r   N)r   z, r   )zworld!
)zIt's nice to meet you.

zIndeed.r   )r   
writelinesrG   r!   r]   s   & r   test_writelinesBuffering)LoggingFileTests.test_writelinesBuffering   s}    
 	()R(	]#o%67	>?JJ	
r   c                   < V ^8  d   QhRR/# r:   r;   )r   r   s   "r   r   r<      s     
8 
8D 
8r   c                    V P                  4       pV P                  \        RV4       \        RRR7       \        R4       V P	                  VP
                  R.4       R# )z+
L{LoggingFile} can replace L{sys.stdout}.
stdoutzHello, )endzworld.zHello, world.N)r   patchrw   printrG   r!   r]   s   & r   
test_printLoggingFileTests.test_print   sJ     

3!$hC ho%67r   Nc                <   < V ^8  d   QhRS[ RS[S[,          RS[/# )r   r   r   r   )r   r   r   r   )r   r   s   "r   r   r<     s-       3- 
	r   c                   a . o\        \        4      R V3R ll4       p\        VR7      pSP                  \	        WAVR7      4       S^ ,          # )al  
Construct a L{LoggingFile} with a built-in observer.

@param level: C{level} argument to L{LoggingFile}
@param encoding: C{encoding} argument to L{LoggingFile}

@return: a L{TestLoggingFile} with an observer that appends received
    events into the file's C{events} attribute (a L{list}) and
    event messages into the file's C{messages} attribute (a L{list}).
c                (    V ^8  d   QhR\         RR/# r&   r(   )r   s   "r   r   3LoggingFileTests.observedFile.<locals>.__annotate__  s     	# 	#H 	# 	#r   c                 &   < S^ ,          ! V 4       R# )    Nr;   )r'   loggingFiless   &r   r?   /LoggingFileTests.observedFile.<locals>.observer  s    OE"r   r>   r   )r   r   r   r+   r   )r"   r   r   r?   logr   s   &&&  @r   r   LoggingFileTests.observedFile  sL    & /1	\	"	# 
#	# h'O3hWXAr   )r   r@   )r.   r/   r0   r1   r2   rA   rJ   r_   rl   rr   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   r3   r   r4   r5   )r   s   @r   r8   r8   -   s     6 6
 

E 
E/ /2 2. .& && &S S8 8 ) )% %
 
&@ @@ @C C@ @
 
(
8 
8  (}}"&  r   r8   )r2   rw   typingr   r   zope.interfacer   
constantlyr   twisted.trialr   _interfacesr   r   _ior	   _levelsr
   _loggerr   	_observerr   r   TestCaser8   r;   r   r   <module>r      s^     ! & $ " 0    $ \2k 2 2*tx(( tr   