U
    n5{iô[  ã                   @   s:  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	k
rL   dZY nX 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eeedœdd„Zddœdd„Zddœd	d
„Z	ddœdd„Z
ddœdd„Zddœdd„Zddœdd„Zddœdd„Zddœdd„Zd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_format)r   ÚassertIsÚtypeÚstr)Úselfr   r   Úresult© r"   úC/tmp/pip-unpacked-wheel-mnhg7r0q/twisted/logger/test/test_format.pyÚformat'   s    zFormattingTests.formatN©r   c                 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   s   dS )NÚyesr"   r"   r"   r"   r#   Ú<lambda>I   r'   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edœdd„ZdS )z0FormattingTests.test_formatMethod.<locals>.Worldr%   c                 S   s   dS )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{   s    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   s   dd S ©NrG   r   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…   s    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   rK   rN   c                   S   s   dd S rL   r"   r"   r"   r"   r#   r,   •   r'   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.
        rK   c                   S   s   dd S rL   r"   r"   r"   r"   r#   r,   £   r'   zUFormattingTests.test_formatUnformattableEventWithUnformattableValue.<locals>.<lambda>)r   rN   rP   rQ   rR   rS   N)rB   rT   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 )
rV   rK   c                   S   s   dd S rL   r"   r"   r"   r"   r#   r,   ±   r'   zbFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop.<locals>.<lambda>Úokay)r   rN   ÚrecoverablerQ   rY   z = N)rB   r   r   ÚBaseExceptionrT   r3   r4   rH   r"   r"   r#   Ú@test_formatUnformattableEventWithUnformattableErrorOMGWillItStop«   s    ýzPFormattingTests.test_formatUnformattableEventWithUnformattableErrorOMGWillItStop)r9   r:   r;   Ú__doc__r   rE   r   r$   r5   r>   rF   rI   rJ   rO   rU   rW   r[   r"   r"   r"   r#   r   "   s   "	

r   c                   @   sd   e Zd ZdZddœdd„Zddœdd„Zddœdd	„Zddœd
d„Zddœdd„Zddœdd„Z	dS )ÚTimeFormattingTestsz.
    Tests for time formatting functions.
    Nr%   c                 C   s   t | ƒ d S )N)r	   r7   r"   r"   r#   ÚsetUp¿   s    zTimeFormattingTests.setUpc                    s`   t dkrtdƒ‚ttt tddœ‡ 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                    s@   t | ƒ tdƒ}ˆ  t|ƒ|¡ |r<tdƒ}ˆ  t|ƒ|¡ d S )N)	i×  rG   é   r   r   r   r   rc   r   )	iÖ  é   é   r   r   r   é   éµ   rG   )r   r
   r2   r   )r`   ra   rb   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    rh   r"   r7   r#   Ú test_formatTimeWithDefaultFormatÂ   s6      þýýýý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©Ú
timeFormatrk   rl   )rx   rm   ©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.
        rp   z%Y/%Wrw   z2013/38Nry   rz   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%frw   Z234560Nrn   r7   r"   r"   r#   Útest_formatTimePercentF  s    z+TimeFormattingTests.test_formatTimePercentF)
r9   r:   r;   r\   r^   rj   ro   r|   r}   r~   r"   r"   r"   r#   r]   º   s   0r]   c                   @   sª   e Zd ZdZddœdd„Zddœdd„Zddœdd	„Zddœd
d„Zddœdd„Zddœdd„Z	ddœdd„Z
ddœdd„Zddœdd„Zddœdd„Zddœdd„ZdS )ÚClassicLogFormattingTestsz@
    Tests for classic text log event formatting functions.
    Nr%   c                 C   sH   t dk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.
        Nr_   ri   rp   Ú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   s8   t t tdœ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   -  s    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   s    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  s
    þ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@  s
    þz*ClassicLogFormattingTests.test_formatLevelc                 C   s    t ddd�}|  t|ƒd¡ dS )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  s
    þ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   rT   r2   r   rŠ   r"   r"   r#   Útest_formatSystemUnformattablec  s
    þz8ClassicLogFormattingTests.test_formatSystemUnformattablec                 C   s    t ddd�}|  t|ƒd¡ dS )z0
        Formatted event is last field.
        zid:{id}Ú123©r   Úidz- [-#-] id:123
Nr‰   rŠ   r"   r"   r#   Útest_formatFormatm  s
    þ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_formatFormatMultiLine)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d„ZdS )ÚFormatFieldTestsz+
    Tests for format field functions.
    Nr%   c                 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   s   dS )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   s   dS )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_formatWithCall)r9   r:   r;   r\   r¢   r"   r"   r"   r#   r    �  s   r    c                   @   s   e Zd ZdZedœdd„ZdS )rT   z>
    An object that raises an exception from C{__repr__}.
    r%   c                 C   s   t dd ƒS rL   )r   r7   r"   r"   r#   Ú__repr__®  s    zUnformattable.__repr__N)r9   r:   r;   r\   r   r£   r"   r"   r"   r#   rT   ©  s   rT   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d„Zddœdd„Zddœdd	„Zddœd
d„Zddœdd„Zddœdd„Z	ddœdd„Z
ddœdd„Zddœdd„Zddœdd„Zddœdd„Zddœdd„Zddœdd„Zddœdd„ZdS ) ÚEventAsTextTestszi
    Tests for L{eventAsText}, all of which ensure that the
    returned type is UTF-8 decoded text.
    Nr%   c                 C   sj   zt dƒ‚W n t k
r&   tƒ }Y nX 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   sj   zt dƒ‚W n t k
r&   tƒ }Y nX 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   s|   zt dƒ‚W n t k
r&   tƒ }Y nX 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¦   rK   c                   S   s   dd S rL   r"   r"   r"   r"   r#   r,   è  r'   zHEventAsTextTests.test_formatUnformattableWithTraceback.<locals>.<lambda>rM   r¨   TFr©   N)r¤   r   r   ÚassertIsInstancer   r3   r­   r®   r"   r"   r#   Ú%test_formatUnformattableWithTracebackÜ  s    þz6EventAsTextTests.test_formatUnformattableWithTracebackc                 C   s–   zt dƒ‚W n t k
r&   tƒ }Y nX 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   rK   rN   c                   S   s   dd S rL   r"   r"   r"   r"   r#   r,   ý  r'   zMEventAsTextTests.test_formatUnformattableErrorWithTraceback.<locals>.<lambda>rP   r¨   TFr©   zMESSAGE LOSTN)	r¤   r   r   r   rT   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   sb   zt dƒ‚W n t k
r&   tƒ }Y nX 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   sb   zt dƒ‚W n t k
r&   tƒ }Y nX 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   sd   zt dƒ‚W n t k
r&   tƒ }Y nX 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¦   rp   Ú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krtdƒ‚t| ƒ tdƒ ztdƒ‚W n tk
rF   tƒ }Y nX 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.
        Nr_   ri   r¦   rp   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  s0    ýüþz.EventAsTextTests.test_eventAsTextTimestampOnlyc                 C   sb   zt dƒ‚W n t k
r&   tƒ }Y nX 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¦   rp   r½   r�   r¨   FTrÀ   z
[-#-] ABCDNrÁ   rÂ   r"   r"   r#   Útest_eventAsTextSystemMissingy  s&    þüþz.EventAsTextTests.test_eventAsTextSystemMissingc                 C   sh   zt dƒ‚W n t k
r&   tƒ }Y nX 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¦   rp   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   sf   zt dƒ‚W n t k
r&   tƒ }Y nX 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¦   rp   r½   )r   r‚   rŒ   r¨   FTrÀ   z[-#info] ABCDNrÇ   rÂ   r"   r"   r#   Ú&test_eventAsTextSystemMissingLevelOnly±  s(    ýüþz7EventAsTextTests.test_eventAsTextSystemMissingLevelOnlyc                 C   sZ   t tt dœ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   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_eventAsTextTypeAsInput)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   r]   r   r    rT   Ú	Exceptionr¤   r¥   r"   r"   r"   r#   Ú<module>   s,   
  U 	