
    tf                        d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ  ed          Z ed	          Z G d
 dee                   Zdeegef         dee         dee         fdZddee         dedee         fdZdS )z5
Hamcrest matchers useful throughout the test suite.
    )IOCallableOptionalTypeVar)BaseMatcher)Description)Matcher)	IFilePath)fullyQualifiedName_A_Bc                        e Zd ZdZdeegef         dee         ddfdZdede	fdZ
ded	eddf fd
ZdeddfdZ xZS )_MatchAftera(  
    The implementation of L{after}.

    @ivar f: The function to apply.
    @ivar m: The matcher to use on the result.

    @ivar _e: After trying to apply the function fails with an exception, the
        exception that was raised.  This can later be used by
        L{describe_mismatch}.
    fmreturnNc                 0    || _         || _        d | _        d S N)r   r   _e)selfr   r   s      Z/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/trial/test/matchers.py__init__z_MatchAfter.__init__!   s    '+    itemc                     	 |                      |          }| j                            |          S # t          $ r}|| _        Y d}~dS d}~ww xY w)zI
        Apply the function and delegate matching on the result.
        NF)r   r   matches	Exceptionr   )r   r   transformedes       r   _matchesz_MatchAfter._matches&   sa    	/&&,,K
 6>>+...	  	 	 	DG55555	s   1 
AAAmismatch_descriptionc           	          | j         $t                                          ||           dS |                    t	          | j                   d|dt	          | j         j                   d| j                     dS )a  
        Describe the mismatching item or the exception that occurred while
        pre-processing it.

        @note: Since the exception reporting here depends on mutable state it
            will only work as long as PyHamcrest calls methods in the right
            order.  The PyHamcrest Matcher interface doesn't seem to allow
            implementing this functionality in a more reliable way (see the
            implementation of L{assert_that}).
        N(z	) raised
z: )r   superdescribe_mismatchappend_textr   r   	__class__)r   r   r!   r'   s      r   r%   z_MatchAfter.describe_mismatch2   s     7?GG%%d,@AAAAA ,,%df-- F F F F%dg&788F F<@GF F    r   descriptionc                 v    |                     d| j         d           | j                            |           dS )zE
        Create a text description of the match requirement.
        z[after z] N)r&   r   r   describe_to)r   r(   s     r   r*   z_MatchAfter.describe_toE   sB     	 4$& 4 4 4555;'''''r   )__name__
__module____qualname____doc__r   r   r   r	   r   boolr    r   r%   r*   __classcell__)r'   s   @r   r   r      s        	 	,(B48, , , , , , ,

/R 
/D 
/ 
/ 
/ 
/b  PT      &({ (t ( ( ( ( ( ( ( (r   r   r   r   r   c                 "    t          | |          S )zN
    Create a matcher which calls C{f} and uses C{m} to match the result.
    )r   )r   r   s     r   afterr2   M   s     q!r   utf-8encodingc                 L    dt           dt          ffd}t          ||           S )ze
    Create a matcher which matches a L{FilePath} the contents of which are
    matched by L{m}.
    pr   c                     |                                  5 }|                                                              cd d d            S # 1 swxY w Y   d S r   )openreaddecode)r6   r   r4   s     r   
getContentz fileContents.<locals>.getContentZ   s    VVXX 	-6688??8,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   'A

AA)r
   strr2   )r   r4   r;   s    ` r   fileContentsr=   T   sA    -i -C - - - - - -
 Qr   N)r3   )r.   typingr   r   r   r   hamcrest.core.base_matcherr   hamcrest.core.descriptionr   hamcrest.core.matcherr	   twisted.python.filepathr
   twisted.python.reflectr   r   r   r   r2   r<   r=    r   r   <module>rE      sU    3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 ) ) ) ) ) ) - - - - - - 5 5 5 5 5 5WT]]WT]]5( 5( 5( 5( 5(+b/ 5( 5( 5(pXrdBh GBK GBK       GCL  C  gi>P            r   