
    Bh1K                       d 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 ddlm	Z	 ddlm
Z
 dd	lZdd	lZdd	lZdd	lZdd
lmZ ddlmZ dd	l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 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# ddl$m%Z% ddl$m&Z& ddl$m'Z' ddl(m)Z) dd	l*Z*ejV                  d	d dk  rddl,m-Z- erdd	l.Z.dd	l/Z0ee1e2e3   e3ejh                  f   e1d   f   Z5	 	 	 	 	 	 	 	 d/dZ6 G d d e%      Z7 G d! d"e&      Z8 ed#$      d0d%       Z9d1d&Z:d2d'Z; G d( d)e
      Z<d3d*Z=d+Z> ed#,      d4d-       Z?	 	 	 	 d5d.Z@y	)6z4Discover and run std-library "unittest" style tests.    )annotations)Callable)	Generator)Iterable)Iterator)auto)EnumN)TYPE_CHECKING)Union)is_async_function)hookimpl)FixtureRequest)MonkeyPatch)	Collector)Item)exit)fail)skip)xfail)Class)Function)Module)CallInfo   )      )ExceptionGroup)NNNc                    	 t         j                  d   }t        ||j                        sy 	 t        j                  |      ry t        j                  | ||      S # t        $ r Y y w xY w)Nunittest)nameobj)	sysmodules
issubclassTestCase	Exceptioninspect
isabstractUnitTestCasefrom_parent)	collectorr    r!   uts       [/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/_pytest/unittest.pypytest_pycollect_makeitemr.   4   sl    [[$ #r{{+ , ###IDc#BB  s   )A 	A'&A'c                  .    e Zd ZdZd ZddZddZddZy)	r)   Tc                $    | j                  d      S )NrunTestr!   selfs    r-   newinstancezUnitTestCase.newinstanceM   s     xx	""    c              #    K   ddl m} | j                  }t        |dd      sy t	        |      }|s2| j                  |       | j                  |       | j                          | j                  j                  j                  | j                         | j                          |       }d}|j                  | j                        D ]A  }t        | j                  |      }t        |dd      s't        j                  | |       d}C |spt        | j                  dd       }|Vt         j"                  j%                  dd       }	|	||	j&                  j(                  k7  rt        j                  | d       y y y y w)	Nr   )
TestLoader__test__TF)r    r1   twisted.trial.unittest)r   r8   r!   getattr_is_skipped'_register_unittest_setup_method_fixture&_register_unittest_setup_class_fixture_register_setup_class_fixturesession_fixturemanagerparsefactoriesr5   nodeidgetTestCaseNamesTestCaseFunctionr*   r"   r#   getr%   r1   )
r4   r8   clsskippedloaderfoundsomethingr    xruntestr,   s
             r-   collectzUnitTestCase.collectU   sJ    'hhsJ-c"88=77<..0$$33D4D4D4FT++DHH5D$'A1j$/"..t$.??!N 6 dhh	48G"[[__%=tD:BKK,?,?!?*66t)6LL "@ # s   E9E;c                   t        dd      t        dd      yt        dd       dfd	 	 	 	 dfd}| j                  j                  j                  dj                   || j
                  d	d
       y)zSRegister an auto-use fixture to invoke setUpClass and
        tearDownClass (#517).
setUpClassNtearDownClassdoClassCleanupsc                      y N rT   r6   r-   <lambda>zEUnitTestCase._register_unittest_setup_class_fixture.<locals>.<lambda>{   s    $r6   c                     t        dd       } | sy | D cg c]  \  }}}|
 }}}t        |      dk(  r|d   t        d|      c c}}w )NtearDown_exceptions   r   zUnittest class cleanup errors)r;   lenr   )	exc_infos_exc
exceptionsrG   s       r-   process_teardown_exceptionszXUnitTestCase._register_unittest_setup_class_fixture.<locals>.process_teardown_exceptions}   s_      %:DAI1:;+1c1#J; :!# m#$%DjQQ <s   Ac              3  @  K   | j                   }t        |      r-|j                  }t        j                  j                  |d      	          d  	                            y # t
        $ r                    w xY w#                   w xY wwNT)_use_item_location)rG   r<   __unittest_skip_why__pytestr   r&   )requestrG   reasoncleanupr^   setupteardowns      r-   unittest_setup_class_fixturezYUnitTestCase._register_unittest_setup_class_fixture.<locals>.unittest_setup_class_fixture   s      ++C322kk++Ft+LL G .'J	+- ! I/1 	+-s6   ABA/ B	B  B/BBBB_unittest_setUpClass_fixture_classTr    funcrC   scopeautousereturnNonerd   r   rq   zGenerator[None]r;   r@   rA   _register_fixture__qualname__rC   )r4   rG   ri   rf   r^   rg   rh   s    ` @@@@r-   r>   z3UnitTestCase._register_unittest_setup_class_fixturet   s     \4036=X-#0,?	R	.#	.	. 	.0 	$$6601A1A0BC-;; 	7 	
r6   c                    t        |dd      t        |dd      y	 	 	 	 d	fd}| j                  j                  j                  d|j                   || j
                  dd       y)
zWRegister an auto-use fixture to invoke setup_method and
        teardown_method (#517).setup_methodNteardown_methodc              3     K   | j                   }t        |      r-|j                  }t        j                  j                  |d       || j                         d   || j                         y y wr`   )instancer<   rb   rc   r   r&   function)rd   r4   re   rg   rh   s      r-   unittest_setup_method_fixturez[UnitTestCase._register_unittest_setup_method_fixture.<locals>.unittest_setup_method_fixture   su      ##D4 33kk++Ft+LL dG,,-#w//0 $s   A5A8_unittest_setup_method_fixture_r|   Trl   rs   rt   )r4   rG   r}   rg   rh   s      @@r-   r=   z4UnitTestCase._register_unittest_setup_method_fixture   s     ^T23 148=X-	1#	1	1 	$$66233C3C2DE.;; 	7 	
r6   N)rq   zIterable[Item | Collector])rG   typerq   rr   )__name__
__module__rv   
nofuncargsr5   rM   r>   r=   rT   r6   r-   r)   r)   H   s     J#M>6
p
r6   r)   c                       e Zd ZU dZdZded<   d Zed        Zd fdZ	d fdZ
dd	Zdd
Z	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZddZ	 d	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZddZddZddZddZ	 	 	 	 d fdZ xZS ) rE   TNz7list[_pytest._code.ExceptionInfo[BaseException]] | None_excinfoc                    t        | j                  t              sJ | j                  j                  | j                        S rS   )
isinstanceparentr)   r!   r    r3   s    r-   _getinstancezTestCaseFunction._getinstance   s-    $++|444{{tyy))r6   c                    | j                   S rS   )r{   r3   s    r-   	_testcasezTestCaseFunction._testcase   s    }}r6   c                0    d | _         t        | 	          y rS   )_explicit_tearDownsuperrg   r4   	__class__s    r-   rg   zTestCaseFunction.setup   s    =Ar6   c                z    | j                   | j                          d | _         d | _        | `t        |           y rS   )r   _obj	_instancer   rh   r   s    r-   rh   zTestCaseFunction.teardown   s:    "".##%&*D#	Nr6   c                     y rS   rT   r4   testcases     r-   	startTestzTestCaseFunction.startTest       r6   c                   t        |      }	 t        j                  j                  t           j                  |      }|j                  }|j                  }| j                   j#                  dg       j%                         y # t        $ r 	 	 t        j                  | }|j                  dd       t        dj                  |      d       n8# t        j                  t        f$ r  t        $ r t        d|d       Y nw xY wnJ# t        $ r  t        j                  $ r+ t        j                  j                  j                         }Y nw xY wY w xY w)Nr   zCNOTE: Incompatible Exception Representation, displaying natively:

 Fpytracez6ERROR: Unknown Incompatible Exception representation:
r   )_handle_twisted_exc_info_pytest_codeExceptionInfoBaseExceptionfrom_exc_infovalue	traceback	TypeErrorformat_exceptioninsertr   joinr&   KeyboardInterruptfrom_current__dict__
setdefaultappend)r4   
rawexcinfoexcinfor[   valuess        r-   _addexcinfozTestCaseFunction._addexcinfo   s8   -j9
	Emm11-@NNG
 A!!A. 	  R077@-  	EE&77DFMM3
 %8(9: $ ,,6>; % % >> E!--55BBDE)	EsV   AB 	EA CD2D?DDDEAE
EEEEc                    	 t        |d   t        j                        rt        |d   j                         | j                  |       y # t        $ r Y w xY w)NrX   )r   r   r&   msgr   r   r4   r   r   s      r-   addErrorzTestCaseFunction.addError  sO    	*Q-8Z]&&' 	$  		s   5A	 		AAc                &    | j                  |       y rS   )r   r   s      r-   
addFailurezTestCaseFunction.addFailure  s     	$r6   c                    	 t         j                  j                  |d      # t        j                  $ r& | j                  t	        j
                                Y y w xY wr`   )rc   r   r&   r   r"   exc_info)r4   r   re   s      r-   addSkipzTestCaseFunction.addSkip  sH    	-++''4'HH~~ 	-S\\^,	-s   !# 6AAc                    	 t        t        |             y # t         j                  $ r& | j                  t	        j
                                Y y w xY wrS   )r   strr&   r   r"   r   )r4   r   r   re   s       r-   addExpectedFailurez#TestCaseFunction.addExpectedFailure   s:    	-#f+ 	-S\\^,	-s    6AAc                    d}|r|d|j                    z  }	 t        |d       y # t        j                  $ r& | j                  t	        j
                                Y y w xY w)NzUnexpected successz: Fr   )re   r   r&   r   r"   r   )r4   r   re   r   s       r-   addUnexpectedSuccessz%TestCaseFunction.addUnexpectedSuccess+  sW    
 #R''C	-e$~~ 	-S\\^,	-s   & 6AAc                     y rS   rT   r   s     r-   
addSuccesszTestCaseFunction.addSuccess9  r   r6   c                     y rS   rT   r   s     r-   stopTestzTestCaseFunction.stopTest<  r   r6   c                     y rS   rT   )r4   r   elapseds      r-   addDurationzTestCaseFunction.addDuration?  r   r6   c                R   ddl m} | j                  }|J  ||        t        | j                        r
 ||        y t        | j                  t              sJ t        | j                        xs t        | j                  j                        }| j                  j                  d      r!|s|j                  | _        t        |dd        t        || j                  | j                         	  ||        t        || j                         y # t        || j                         w xY w)Nr   )&maybe_wrap_pytest_function_for_tracing)resultusepdbtearDownc                      y rS   rT   )argss    r-   rU   z*TestCaseFunction.runtest.<locals>.<lambda>Y  s    Dr6   )_pytest.debuggingr   r{   r   r!   r   r   r)   r<   config	getoptionr   r   setattrr    delattr)r4   r   r   rH   s       r-   rL   zTestCaseFunction.runtestB  s    L==###.t4 TXX&D! dkk<888!$((+K{4;;??/KG{{$$X.w*2*;*;'*.@A Hdii2-%$)),$)),s   .	D D&c                T    t         |   |      } |j                  d       }|s|}|S )Nc                N    | j                   j                  j                  d       S )N
__unittest)frame	f_globalsrF   )rK   s    r-   rU   z4TestCaseFunction._traceback_filter.<locals>.<lambda>h  s    !''++//==r6   )r   _traceback_filterfilter)r4   r   r   
ntracebackr   s       r-   r   z"TestCaseFunction._traceback_filterc  s9     G-g6	%Y%%=

 "Jr6   rp   )r   unittest.TestCaserq   rr   )r   _SysExcInfoTyperq   rr   )r   r   r   r   rq   rr   )r   r   re   r   rq   rr   )r   )r   r   r   r   re   r   rq   rr   rS   )r   r   re   z"twisted.trial.unittest.Todo | Nonerq   rr   )r   r   r   floatrq   rr   )r   z*_pytest._code.ExceptionInfo[BaseException]rq   z_pytest._code.Traceback)r   r   rv   r   r   __annotations__r   propertyr   rg   rh   r   r   r   r   r   r   r   r   r   r   rL   r   __classcell__)r   s   @r-   rE   rE      s   JHLHEL*  
 AD%)%7F%	%%)%7F%	%
- 		-#	- $	- 		-
 
	- 6:-#- 3- 
	--B	A		 	 	r6   rE   T)tryfirstc                   t        | t              r/| j                  r#| j                  j                  d      |_        	 |`t        j                  j                  d      }|r||j                  rot        |j                  j                  |j                        rD|j                  t        d    j                  fd|j                        }|j                  |_        y y y y # t        $ r Y w xY w)Nr   r   c                 T    t        j                  t         j                              S rS   )rc   r   r   r   )r   s   r-   rU   z+pytest_runtest_makereport.<locals>.<lambda>  s    FKKGMM 23r6   )r   rE   r   popr   r   AttributeErrorr"   r#   rF   r   SkipTestr   	from_callwhen)itemcallr   call2r   s       @r-   pytest_runtest_makereportr   o  s    $()====,,Q/DLK {{z*HDLLZ0B0BHDUDU%V,,((3TYY
 }} &WLx " s   C 	C+*C+c                .    t        t        | dd            S )zDReturn True if the given object has been marked with @unittest.skip.__unittest_skip__F)boolr;   r2   s    r-   r<   r<     s    0%899r6   c                 l    t               t        j                  urddlm}  ddlm}  |t        |        yy)zRRegister the TestCaseFunction class as an IReporter if twisted.trial is available.r   )	IReporter)classImplementsN)_get_twisted_versionTwistedVersionNotInstalledtwisted.trial.itrialr   zope.interfacer   rE   )r   r   s     r-   pytest_configurer     s*    ^%@%@@22()4	 Ar6   c                  :    e Zd ZdZ e       Z e       Z e       Zy)r   z
    The Twisted version installed in the environment.

    We have different workarounds in place for different versions of Twisted.
    N)r   r   rv   __doc__r   	Version24	Version25r   rT   r6   r-   r   r     s     II6Lr6   r   c                     dt         j                  vrt        j                  S dd l} dd l}| j                  j                  d      }|j                  j                  |      }|j                  dk  rt        j                  S t        j                  S )Nr:   r   twisted   )r"   r#   r   r   importlib.metadatapackaging.versionmetadataversionparsemajorr   r   )	importlib	packagingversion_strr  s       r-   r   r     sr      s{{2***$$,,Y7K%%k2G}}''''''r6   _twisted_raw_excinfo)wrapperc              #  *  K   t               t        j                  u redd lmc m} |j                  j                  	 dfd	}t        j                         5 }|j                  |j                  d|       d cd d d        S d S # 1 sw Y   y xY ww)Nr   c                   |t        j                         }n+|t        |      }|t        j                         d   }|||f}t        | t        t        |             	  | ||||       y # t        $ r  | |||       Y y w xY w)Nr   )captureVars)r"   r   r   r   TWISTED_RAW_EXCINFO_ATTRtupler   )r4   	exc_valueexc_typeexc_tbr  raw_exc_infooriginal__init__s         r-   store_raw_exception_infoz9pytest_runtest_protocol.<locals>.store_raw_exception_info  s      "||~##IH> \\^A.F ()V<D2E,4GHD )Xv;  D y(FCDs   A- -BB__init__)NNNN)r   r   r   twisted.python.failurepythonfailureFailurer  r   contextr   )r   r,   r  patcherr  s       @r-   pytest_runtest_protocolr    s|     !9!99++ ::.. KO	D&   "gOOBJJ
4LM #" 	 #"s   AB!B9BBBc                   t               }|t        j                  u r| S |t        j                  u r4t	        | t
              r"t        | t
              }t        | t
               |S | S |t        j                  u rt        | t              ruddl}t        | |j                  j                  j                        rG| j                  }|t!        j"                         d   }t%        | j&                        | j&                  |fS | S J d|        )z
    Twisted passes a custom Failure instance to `addError()` instead of using `sys.exc_info()`.
    Therefore, if `rawexcinfo` is a `Failure` instance, convert it into the equivalent `sys.exc_info()` tuple
    as expected by pytest.
    r   Nr   zUnexpected Twisted version: )r   r   r   r   hasattrr  r;   r   r   r   r   r  r  r  r  __traceback__r"   r   r   r   )r   twisted_versionsaved_exc_infor   tbs        r-   r   r     s     +,O.555 	N44	4 :78$Z1IJNJ 89!!	N44	4j-0)*gnn&<&<&D&DE--:*BJ,,-z/?/?CC 	G4_4EFFur6   )r+   zModule | Classr    r   r!   objectrq   zUnitTestCase | None)r   r   r   zCallInfo[None]rq   rr   )rq   r   rp   )rq   r   )r   r   rq   zIterator[None])r   z_SysExcInfoType | BaseExceptionrq   r   )Ar   
__future__r   collections.abcr   r   r   r   enumr   r	   r'   r"   r   typestypingr
   r   _pytest._coder   _pytest.compatr   _pytest.configr   _pytest.fixturesr   _pytest.monkeypatchr   _pytest.nodesr   r   _pytest.outcomesr   r   r   r   _pytest.pythonr   r   r   _pytest.runnerr   rc   version_infoexceptiongroupr   r   twisted.trial.unittestr   r  r   r   TracebackTyper   r.   r)   rE   r   r<   r   r   r   r  r  r   rT   r6   r-   <module>r6     sl   : " $ % $ $    
       , # + + #  ! ! ! "   # ! #  BQ'!-! 	$}
}e.A.A
AB	
CC%(C/5CC(@
5 @
Fax aH 
4% %,:
5T (, 2  
$ B&G/&G&Gr6   