o
    Òó·iô[  ã                   @   s8  d Z ddlmZmZmZmZmZ z
ddlmZ e W n e	y%   dZY nw ddl
mZ ddlmZmZmZ ddlmZ ddlmZ d	d
lmZmZmZmZmZmZ d	dlmZ d	dlmZ G dd„ dejƒZ G dd„ dejƒZ!G dd„ dejƒZ"G dd„ dejƒZ#G dd„ dƒZ$G dd„ de%ƒZ&G dd„ dejƒZ'dS )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                   @   s€   e Zd ZdZdededefdd„Zddd	„Zdd
d„Z	ddd„Z
ddd„Zddd„Zddd„Zddd„Zddd„Zddd„ZdS )ÚFormattingTestsz5
    Tests for basic event formatting functions.
    Ú	logFormatÚeventÚreturnc                 K   s$   ||d< t |ƒ}|  t|ƒt¡ |S )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_formatN)r   ÚassertIsÚtypeÚstr)Úselfr   r   Úresult© r!   úeC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/logger/test/test_format.pyÚformat'   s   zFormattingTests.formatNc                 C   sÂ   |   d|  d¡¡ |   d|  d¡¡ |   d| jddd�¡ |   d| jddd	d
„ d�¡ |   d|  d¡¡ |  d|  d¡¡ | jddd�}|  d|¡ ttdƒƒ}|  d| d | jddd�¡ dS )ac  
        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.
        Ú ó    Úabcz{x})Úxzno, yes.z{not_called}, {called()}.Únoc                   S   ó   dS )NÚyesr!   r!   r!   r!   r"   Ú<lambda>I   ó    z2FormattingTests.test_formatEvent.<locals>.<lambda>)Z
not_calledÚcalledu   SÃ¡nchezs   SÃ¡nchezúUnable to format events   Sánchezs   S{a!s}nchezó   á)ÚazSb'\xe1'nchezÚSZnchezs   S{a!r}nchezN)ÚassertEqualr#   ÚassertInr   Úrepr)r   ZmaybeResultZxe1r!   r!   r"   Útest_formatEvent2   s   
ÿþ"z FormattingTests.test_formatEventc                 C   s*   G dd„ dƒ}|   d| jd|ƒ d�¡ dS )zq
        L{formatEvent} will format PEP 3101 keys containing C{.}s ending with
        C{()} as methods.
        c                   @   s   e Zd Zdefdd„ZdS )z0FormattingTests.test_formatMethod.<locals>.Worldr   c                 S   r)   )NÚworldr!   ©r   r!   r!   r"   Úwhere[   s   z6FormattingTests.test_formatMethod.<locals>.World.whereN)Ú__name__Ú
__module__Ú__qualname__r   r8   r!   r!   r!   r"   ÚWorldZ   s    r<   zhello worldzhello {what.where()})ÚwhatN)r2   r#   )r   r<   r!   r!   r"   Útest_formatMethodT   s   ÿz!FormattingTests.test_formatMethodc                 C   s,   G dd„ dt ƒ}|  d| jd|ƒ d�¡ dS )zS
        L{formatEvent} will format subscripts of attributes per PEP 3101.
        c                   @   s*   e Zd ZU eddd�Zeeef ed< dS )z>FormattingTests.test_formatAttributeSubscript.<locals>.ExampleÚbarZqux)ÚfooZbazÚconfigN)r9   r:   r;   ÚdictrA   r   r   Ú__annotations__r!   r!   r!   r"   ÚExampleg   s   
  rD   zbar quxz+{example.config[foo]} {example.config[baz]})ZexampleN)Úobjectr2   r#   )r   rD   r!   r!   r"   Útest_formatAttributeSubscriptb   s   þþz-FormattingTests.test_formatAttributeSubscriptc                 C   s$   t ddd�}t|ƒ}|  d|¡ dS )z5
        Formatting an event with no format.
        é   r   )r@   r?   r$   N)rB   r   r2   ©r   r   r    r!   r!   r"   Útest_formatEventNoFormatr   s   z(FormattingTests.test_formatEventNoFormatc                 C   s8   t tƒ ddd�}t|ƒ}|  d|¡ |  t|ƒ|¡ dS )z:
        Formatting an event with a bogus format.
        rG   r   )r   r@   r?   zLog format must be strN)rB   rE   r   r3   r4   rH   r!   r!   r"   Útest_formatEventWeirdFormat{   ó   z+FormattingTests.test_formatEventWeirdFormatc                 C   s8   t ddd„ d�}t|ƒ}|  d|¡ |  t|ƒ|¡ dS )zF
        Formatting an event that's just plain out to get us.
        ú{evil()}c                   S   ó   dd S ©NrG   r   r!   r!   r!   r!   r"   r+   ‰   ó    z?FormattingTests.test_formatUnformattableEvent.<locals>.<lambda>©r   Úevilr.   N)rB   r   r3   r4   rH   r!   r!   r"   Útest_formatUnformattableEvent…   rK   z-FormattingTests.test_formatUnformattableEventc                 C   sL   ddddd„ t ttƒ ƒdi}t|ƒ}|  d|¡ |  d|¡ |  d	|¡ d
S )zR
        Formatting an unformattable event that has an unformattable key.
        r   rL   rQ   c                   S   rM   rN   r!   r!   r!   r!   r"   r+   •   rO   zSFormattingTests.test_formatUnformattableEventWithUnformattableKey.<locals>.<lambda>Úgurkú*MESSAGE LOST: unformattable object logged:úRecoverable data:úException during formatting:N)r   r   ÚUnformattabler   r3   rH   r!   r!   r"   Ú1test_formatUnformattableEventWithUnformattableKey�   s   ýzAFormattingTests.test_formatUnformattableEventWithUnformattableKeyc                 C   sD   t ddd„ tƒ d�}t|ƒ}|  d|¡ |  d|¡ |  d|¡ dS )	úT
        Formatting an unformattable event that has an unformattable value.
        rL   c                   S   rM   rN   r!   r!   r!   r!   r"   r+   £   rO   zUFormattingTests.test_formatUnformattableEventWithUnformattableValue.<locals>.<lambda>)r   rQ   rS   rT   rU   rV   N)rB   rW   r   r3   rH   r!   r!   r"   Ú3test_formatUnformattableEventWithUnformattableValue�   s   ýzCFormattingTests.test_formatUnformattableEventWithUnformattableValuec                 C   sP   t ddd„ dd�}t|tttƒ ƒƒ}|  d|¡ |  tdƒd tdƒ |¡ d	S )
rY   rL   c                   S   rM   rN   r!   r!   r!   r!   r"   r+   ±   rO   zbFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop.<locals>.<lambda>Úokay)r   rQ   ÚrecoverablerT   r\   z = N)rB   r   r   ÚBaseExceptionrW   r3   r4   rH   r!   r!   r"   Ú@test_formatUnformattableEventWithUnformattableErrorOMGWillItStop«   s   ý zPFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop©r   N)r9   r:   r;   Ú__doc__r   rE   r   r#   r5   r>   rF   rI   rJ   rR   rX   rZ   r^   r!   r!   r!   r"   r   "   s    

"


	




r   c                   @   sL   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„Zddd„Zddd„Z	dS )ÚTimeFormattingTestsz.
    Tests for time formatting functions.
    r   Nc                 C   s   t | ƒ d S )N)r	   r7   r!   r!   r"   ÚsetUp¿   ó   zTimeFormattingTests.setUpc                    sf   t du rtdƒ‚dtdtt dtddf‡ fdd„}|d	dd
ƒ |dddƒ |dddƒ |dddƒ dS )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                    sD   t | ƒ tdƒ}ˆ  t|ƒ|¡ |r tdƒ}ˆ  t|ƒ|¡ d S d S )N)	i×  rG   é   r   r   r   r   rh   r   )	iÖ  é   é   r   r   r   é   éµ   rG   )r   r
   r2   r   )re   rf   rg   ZlocalSTDZlocalDSTr7   r!   r"   ÚtestForTimeZoneÊ   s   þzMTimeFormattingTests.test_formatTimeWithDefaultFormat.<locals>.testForTimeZoneú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   rm   r!   r7   r"   Ú test_formatTimeWithDefaultFormatÂ   s>   ÿÿÿþýýýýz4TimeFormattingTests.test_formatTimeWithDefaultFormatc                 C   s(   |   tdƒd¡ |   tddd�d¡ dS )zL
        If C{when} argument is L{None}, we get the default output.
        Nú-ú!)Údefault©r2   r   r7   r!   r!   r"   Útest_formatTimeWithNoTimeò   s   z-TimeFormattingTests.test_formatTimeWithNoTimec                 C   s6   t dƒ}|  t|dd�d¡ |  t|ddd�d¡ dS )zR
        If C{timeFormat} argument is L{None}, we get the default output.
        ©	iÝ  é	   é   é   é(   é/   rG   i  éÿÿÿÿN©Ú
timeFormatrp   rq   )r}   rr   ©r
   r2   r   ©r   Útr!   r!   r"   Útest_formatTimeWithNoFormatù   s   z/TimeFormattingTests.test_formatTimeWithNoFormatc                 C   s    t dƒ}|  t|dd�d¡ dS )z2
        Alternate time format in output.
        ru   z%Y/%Wr|   z2013/38Nr~   r   r!   r!   r"   Ú&test_formatTimeWithAlternateTimeFormat  s   z:TimeFormattingTests.test_formatTimeWithAlternateTimeFormatc                 C   s   |   tddd�d¡ dS )z0
        "%f" supported in time format.
        g’?x€„.Az%fr|   Z234560Nrs   r7   r!   r!   r"   Útest_formatTimePercentF  s   z+TimeFormattingTests.test_formatTimePercentFr_   )
r9   r:   r;   r`   rb   ro   rt   r�   r‚   rƒ   r!   r!   r!   r"   ra   º   s    


0

ra   c                   @   s~   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„Zddd„Zddd„Z	ddd„Z
ddd„Zddd„Zddd„Zddd„ZdS )ÚClassicLogFormattingTestsz@
    Tests for classic text log event formatting functions.
    r   Nc                 C   sH   t du rtdƒ‚t| ƒ tdƒ tdƒ}td|d�}|  t|ƒd¡ dS )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.
        Nrd   rn   ru   ÚXYZZY©r   Úlog_timez%2013-09-24T11:40:47+0000 [-#-] XYZZY
)r   r   r	   r   r
   rB   r2   r   )r   r€   r   r!   r!   r"   Útest_formatTimeDefault  s   þz0ClassicLogFormattingTests.test_formatTimeDefaultc                 C   s:   dt t dtfdd„}tddd�}|  t||d�d	¡ d
S )zc
        Time is first field.  Custom formatting function is an optional
        argument.
        r€   r   c                 S   s   d| › d�S )NÚ__r!   )r€   r!   r!   r"   r   -  rc   zCClassicLogFormattingTests.test_formatTimeCustom.<locals>.formatTimer…   i90  r†   )r   z__12345__ [-#-] XYZZY
N)r   Úfloatr   rB   r2   r   )r   r   r   r!   r!   r"   Útest_formatTimeCustom'  s   
þz/ClassicLogFormattingTests.test_formatTimeCustomc                 C   ó    t ddd�}|  t|ƒd¡ dS )z:
        Namespace is first part of second field.
        r…   úmy.namespace)r   Úlog_namespacez- [my.namespace#-] XYZZY
N©rB   r2   r   ©r   r   r!   r!   r"   Útest_formatNamespace6  ó
   þz.ClassicLogFormattingTests.test_formatNamespacec                 C   s"   t dtjd�}|  t|ƒd¡ dS )z7
        Level is second part of second field.
        r…   )r   Ú	log_levelz- [-#warn] XYZZY
N©rB   r   Úwarnr2   r   r�   r!   r!   r"   Útest_formatLevel@  ó
   þz*ClassicLogFormattingTests.test_formatLevelc                 C   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�   r!   r!   r"   Útest_formatSystemJ  r’   z+ClassicLogFormattingTests.test_formatSystemc                 C   s&   t ddtjdd�}|  t|ƒd¡ dS )úB
        System is not supplanted by namespace and level.
        r…   r�   r˜   )r   rŽ   r“   rš   r›   Nr”   r�   r!   r!   r"   Útest_formatSystemRulzT  s   üþz/ClassicLogFormattingTests.test_formatSystemRulzc                 C   s"   t dtƒ d�}|  t|ƒd¡ dS )r�   r…   r™   z- [UNFORMATTABLE] XYZZY
N)rB   rW   r2   r   r�   r!   r!   r"   Útest_formatSystemUnformattablec  r—   z8ClassicLogFormattingTests.test_formatSystemUnformattablec                 C   rŒ   )z0
        Formatted event is last field.
        zid:{id}Ú123©r   Úidz- [-#-] id:123
Nr�   r�   r!   r!   r"   Útest_formatFormatm  r’   z+ClassicLogFormattingTests.test_formatFormatc                 C   s   t dd�}|  t|ƒd¡ dS )z#
        No format string.
        r    )r¢   N©rB   r   r   r�   r!   r!   r"   Útest_formatNoFormatw  s   
z-ClassicLogFormattingTests.test_formatNoFormatc                 C   s    t ddd�}|  t|ƒd¡ dS )z&
        Empty format string.
        r$   r    r¡   Nr¤   r�   r!   r!   r"   Útest_formatEmptyFormat~  s   z0ClassicLogFormattingTests.test_formatEmptyFormatc                 C   s   t dd�}|  t|ƒd¡ dS )zO
        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�   r!   r!   r"   Útest_formatFormatMultiLine…  s
   
þz4ClassicLogFormattingTests.test_formatFormatMultiLiner_   )r9   r:   r;   r`   rˆ   r‹   r‘   r–   rœ   rž   rŸ   r£   r¥   r¦   r§   r!   r!   r!   r"   r„     s    














r„   c                   @   s   e Zd ZdZddd„ZdS )ÚFormatFieldTestsz+
    Tests for format field functions.
    r   Nc                 C   s>   |   tdtddd„ d�ƒd¡ |   tdtdd„ d	�ƒd
¡ dS )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()}.Zearthc                   S   r)   )NÚmayber!   r!   r!   r!   r"   r+   Ÿ  r,   z6FormatFieldTests.test_formatWithCall.<locals>.<lambda>)r6   ZcallmezHello, earth. maybe.zHello, {repr()!r}.c                   S   r)   )Nr4   r!   r!   r!   r!   r"   r+   ¤  r,   )r4   zHello, 'repr'.N)r2   r   rB   r7   r!   r!   r"   Útest_formatWithCall•  s   þûþz$FormatFieldTests.test_formatWithCallr_   )r9   r:   r;   r`   rª   r!   r!   r!   r"   r¨   �  s    r¨   c                   @   s   e Zd ZdZdefdd„ZdS )rW   z>
    An object that raises an exception from C{__repr__}.
    r   c                 C   s   t dd ƒS rN   )r   r7   r!   r!   r"   Ú__repr__®  rc   zUnformattable.__repr__N)r9   r:   r;   r`   r   r«   r!   r!   r!   r"   rW   ©  s    rW   c                   @   s   e Zd ZdZdS )ÚCapturedErrorz3
    A captured error for use in format tests.
    N)r9   r:   r;   r`   r!   r!   r!   r"   r¬   ²  s    r¬   c                   @   sœ   e Zd ZdZd dd„Zd dd„Zd dd	„Zd d
d„Zd dd„Zd dd„Z	d dd„Z
d dd„Zd dd„Zd dd„Zd dd„Zd dd„Zd dd„Zd dd„ZdS )!ÚEventAsTextTestszi
    Tests for L{eventAsText}, all of which ensure that the
    returned type is UTF-8 decoded text.
    r   Nc                 C   sd   zt dƒ‚ t y   tƒ }Y nw ddi}||d< t|ddd�}|  t| ¡ ƒ|¡ |  d|¡ dS )	zT
        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   r3   r   ÚgetTraceback©r   Úfr   Ú	eventTextr!   r!   r"   Útest_eventWithTraceback¾  s   
ÿz(EventAsTextTests.test_eventWithTracebackc                 C   sd   zt dƒ‚ t y   tƒ }Y nw ddi}||d< t|ddd�}|  t| ¡ ƒ|¡ |  d|¡ dS )	zu
        An event with an empty C{log_format} key appends a traceback from
        the accompanying failure.
        r®   r   r$   r°   TFr±   Nr´   r¶   r!   r!   r"   Ú"test_formatEmptyEventWithTracebackÍ  s   
ÿz3EventAsTextTests.test_formatEmptyEventWithTracebackc                 C   sv   zt dƒ‚ t y   tƒ }Y nw ddd„ dœ}||d< t|ddd	�}|  |t¡ |  t| ¡ ƒ|¡ |  d|¡ d
S )zw
        An event with an unformattable value in the C{log_format} key still
        has a traceback appended.
        r®   rL   c                   S   rM   rN   r!   r!   r!   r!   r"   r+   è  rO   zHEventAsTextTests.test_formatUnformattableWithTraceback.<locals>.<lambda>rP   r°   TFr±   N)r¬   r   r   ÚassertIsInstancer   r3   rµ   r¶   r!   r!   r"   Ú%test_formatUnformattableWithTracebackÜ  s   
ÿþz6EventAsTextTests.test_formatUnformattableWithTracebackc                 C   s�   zt dƒ‚ t y   tƒ }Y nw ddddd„ tttƒ ƒdi}||d< t|d	d
d�}|  |t¡ |  d|¡ |  t| ¡ ƒ|¡ |  d|¡ dS )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   rM   rN   r!   r!   r!   r!   r"   r+   ý  rO   zMEventAsTextTests.test_formatUnformattableErrorWithTraceback.<locals>.<lambda>rS   r°   TFr±   zMESSAGE LOSTN)	r¬   r   r   r   rW   r   r»   r3   rµ   r¶   r!   r!   r"   Ú*test_formatUnformattableErrorWithTracebackð  s   
ÿýz;EventAsTextTests.test_formatUnformattableErrorWithTracebackc                 C   s<   ddi}t ƒ |d< t|ddd�}|  |t¡ |  d|¡ dS )	zk
        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)rE   r   r»   r   r3   ©r   r   r¸   r!   r!   r"   Ú&test_formatEventUnformattableTraceback  s
   
z7EventAsTextTests.test_formatEventUnformattableTracebackc                 C   s2   ddi}t |ddd�}|  |t¡ |  d|¡ dS )zY
        An event with no C{log_failure} key will not have a traceback appended.
        r   r¯   TFr±   N)r   r»   r   r3   r¾   r!   r!   r"   Útest_formatEventNonCritical  s   z,EventAsTextTests.test_formatEventNonCriticalc                 C   s\   zt dƒ‚ t y   tƒ }Y nw ddi}||d< t|ddd�}|  d|¡ |  d|¡ d	S )
zU
        An exception message with multibyte characters is properly handled.
        u   â‚¬r   r¯   r°   TFr±   Ú	TracebackN©r¬   r   r   r3   r¶   r!   r!   r"   Útest_formatTracebackMultibyte  s   
ÿz.EventAsTextTests.test_formatTracebackMultibytec                 C   s\   zt dƒ‚ t y   tƒ }Y nw ddi}||d< t|ddd�}|  d|¡ |  d	|¡ d
S )zj
        An error raised attempting to decode the UTF still produces a
        valid log message.
        s
   ÿþt e s t r   r¯   r°   TFr±   rÁ   z.CapturedError(b"\xff\xfet\x00e\x00s\x00t\x00")NrÂ   r¶   r!   r!   r"   Ú,test_formatTracebackHandlesUTF8DecodeFailure*  s   
ÿz=EventAsTextTests.test_formatTracebackHandlesUTF8DecodeFailurec                 C   s^   zt dƒ‚ t y   tƒ }Y nw tdƒ}dd|dœ}||d< t|dddd	�}|  |d
¡ dS )zq
        If includeSystem is specified as the only option no timestamp or
        traceback are printed.
        r®   ru   ÚABCDÚfake_system©r   rš   r‡   r°   FT©r²   ZincludeTracebackr³   z[fake_system] ABCDN©r¬   r   r
   r   r2   ©r   r·   r€   r   r¸   r!   r!   r"   Útest_eventAsTextSystemOnly;  s*   
ÿýüþz+EventAsTextTests.test_eventAsTextSystemOnlyc                 C   s~   t du rtdƒ‚t| ƒ tdƒ ztdƒ‚ ty    tƒ }Y nw tdƒ}dd|dœ}||d	< t|d
ddd�}|  |d¡ dS )zq
        If includeTimestamp is specified as the only option no system or
        traceback are printed.
        Nrd   rn   r®   ru   rÅ   rÆ   rÇ   r°   TFrÈ   z2013-09-24T11:40:47+0000 ABCD)	r   r   r	   r   r¬   r   r
   r   r2   rÊ   r!   r!   r"   Útest_eventAsTextTimestampOnlyW  s2   
ÿýüþz.EventAsTextTests.test_eventAsTextTimestampOnlyc                 C   s\   zt dƒ‚ t y   tƒ }Y nw tdƒ}d|dœ}||d< t|dddd�}|  |d	¡ d
S )z\
        If includeSystem is specified with a missing system [-#-]
        is used.
        r®   ru   rÅ   r†   r°   FTrÈ   z
[-#-] ABCDNrÉ   rÊ   r!   r!   r"   Útest_eventAsTextSystemMissingy  s(   
ÿþüþz.EventAsTextTests.test_eventAsTextSystemMissingc                 C   sb   zt dƒ‚ t y   tƒ }Y nw tdƒ}d|tjddœ}||d< t|dddd	�}|  |d
¡ dS )z€
        If includeSystem is specified with a missing system but
        namespace and level are present they are used.
        r®   ru   rÅ   Útest)r   r‡   r“   rŽ   r°   FTrÈ   z[test#info] ABCDN©r¬   r   r
   r   Úinfor   r2   rÊ   r!   r!   r"   Ú.test_eventAsTextSystemMissingNamespaceAndLevel”  s,   
ÿüüþz?EventAsTextTests.test_eventAsTextSystemMissingNamespaceAndLevelc                 C   s`   zt dƒ‚ t y   tƒ }Y nw tdƒ}d|tjdœ}||d< t|dddd�}|  |d	¡ d
S )zv
        If includeSystem is specified with a missing system but
        level is present, level is included.
        r®   ru   rÅ   )r   r‡   r“   r°   FTrÈ   z[-#info] ABCDNrÏ   rÊ   r!   r!   r"   Ú&test_eventAsTextSystemMissingLevelOnly±  s*   
ÿýüþz7EventAsTextTests.test_eventAsTextSystemMissingLevelOnlyc                 C   s^   dt dtdt fdd„}|  t tƒ|dtd�¡ |  t tƒ|dtd�¡ |  d|d	t d�¡ d
S )zX
        C{eventAsText} can handle formats that have classes or types as input.
        r   r   r   c                 [   s   t d| i|¥dddd�S )Nr   FrÈ   )r   )r   r   r!   r!   r"   ÚgetTextÒ  s   
üz=EventAsTextTests.test_eventAsTextTypeAsInput.<locals>.getTextz{c})Úcr   z{c.__name__}N)r   r   r2   ÚintÚRuntimeError)r   rÓ   r!   r!   r"   Útest_eventAsTextTypeAsInputÍ  s   z,EventAsTextTests.test_eventAsTextTypeAsInputr_   )r9   r:   r;   r`   r¹   rº   r¼   r½   r¿   rÀ   rÃ   rÄ   rË   rÌ   rÍ   rÑ   rÒ   r×   r!   r!   r!   r"   r­   ¸  s     






	



"

r­   )(r`   Útypingr   r   r   r   r   Útimer   ÚImportErrorZtwisted.python.failurer   Z!twisted.python.test.test_tzhelperr	   r
   r   Ztwisted.trialr   Ztwisted.trial.unittestr   Ú_formatr   r   r   r   r   r   Z_interfacesr   Z_levelsr   ZTestCaser   ra   r„   r¨   rW   Ú	Exceptionr¬   r­   r!   r!   r!   r"   Ú<module>   s0   ÿ  U 	