
    =e8C                         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  G d dej                  Z	 G d dej                  Z
edk    r ej                     dS dS )	    N)
gc_collect)productc                   ,    e Zd Zd Zd Zd Zd Zd ZdS )Test_Assertionsc                 &   |                      dd           |                     dd           |                     | j        | j         dd           |                     | j        | j        dd           |                      ddd           |                     | j        | j         ddd           |                      ddd           |                     ddd           |                     | j        | j         ddd           |                     | j        | j        ddd           |                      t	          d	          t	          d	                     |                     | j        | j        t	          d	          t	          d	                     d S )
Ng1  ?      ?g  ?皙?r   )places   y??inf)assertAlmostEqualassertNotAlmostEqualassertRaisesfailureExceptionfloatselfs    4/usr/lib/python3.11/unittest/test/test_assertions.pytest_AlmostEqualz Test_Assertions.test_AlmostEqual
   s   z3///!!)S111$/0)S	B 	B 	B$/3Z	F 	F 	F 	sC222$/0#s1 	 	F 	F 	F 	q&333!!!VA!666$/0!VA 	 	G 	G 	G$/3Qq 	 	J 	J 	J 	uU||U5\\:::$/1J,,e	6 	6 	6 	6 	6    c                 z   |                      ddd           |                      ddd           |                     ddd           |                     ddd           |                      ddd           |                     | j        | j        ddd           |                     | j        | j         ddd           |                     | j        | j        ddd           |                     t          | j         dddd           |                     t          | j        dddd           t
          j                                        }|t          j        d	          z   }|                      ||t          j        d
	                     |                     ||t          j        d	                     d S )Nr	   r   g      ?)deltag?   )r
   r   
   )seconds      )r   r   r   r   	TypeErrordatetimenow	timedelta)r   firstseconds      r   test_AmostEqualWithDeltaz(Test_Assertions.test_AmostEqualWithDelta!   s   sCs333sCs333!!#s$!777!!#s$!777sCs333$/1Js# 	 	/ 	/ 	/ 	$/1Gs$ 	 	0 	0 	0$/1Js# 	 	/ 	/ 	/ 	)T%;s1A 	 	7 	7 	7)T%>s1A 	 	7 	7 	7 !%%''+B7777uf%-%7%C%C%C 	 	E 	E 	E!!%(0(:1(E(E(E 	" 	G 	G 	G 	G 	Gr   c                    d }|                      t          |t                     |                      t          |t          d                     	 |                      t          d            |                     d           n:# | j        $ r-}|                     dt          |                     Y d }~nd }~ww xY w	 |                      t          |t                     |                     d           n# t          $ r Y nw xY w|                      t                    5 }	 t          # t          $ r}|} d }~ww xY w# 1 swxY w Y   |                     |j	        |           |                      t                    5  t          d          # 1 swxY w Y   	 |                      t                    5  	 d d d            n# 1 swxY w Y   |                     d           n:# | j        $ r-}|                     dt          |                     Y d }~nd }~ww xY w	 |                      t                    5  t          # 1 swxY w Y   	 |                     d           d S # t          $ r Y d S w xY w)Nc                     | N )es    r   _raisez1Test_Assertions.test_assertRaises.<locals>._raise=   s    Gr   keyc                      d S r'   r(   r(   r   r   <lambda>z3Test_Assertions.test_assertRaises.<locals>.<lambda>B   s     r   zassertRaises() didn't failzKeyError not raisedz0assertRaises() didn't let exception pass through)
r   KeyErrorfailr   assertInstr
ValueError	ExceptionassertIs	exception)r   r*   r)   cmexcs        r   test_assertRaisesz!Test_Assertions.test_assertRaises<   so   	 	 	(FH555(FHUOO<<<	4h555 II23333 $ 	9 	9 	9MM/Q88888888	9	Jh
;;; IIHIIII  	 	 	D	 x(( 	B   	 	 	 	 	 	 	 	 	blC(((x(( 	" 	"5//!	" 	" 	" 	" 	" 	" 	" 	"	4""8,,                
 II23333 $ 	9 	9 	9MM/Q88888888	9	J""8,, ! !  ! ! ! ! ! ! ! ! !
 IIHIIIII  	 	 	DD	s   B 
B8#B33B8<!C3 3
D ?D D;D&&
D80D33D88D;;D?D?;FFFG  1F?3G  ?GG  GG   
H*#HHI  5H==II  II   
I.-I.c                 ~    G d d          d  G fddt           j                  } |d                                           t                       |                                              |d                                           t                       |                                             d S )Nc                       e Zd ZdS )<Test_Assertions.test_assertRaises_frames_survival.<locals>.AN)__name__
__module____qualname__r(   r   r   Ar;   i   s        Dr   r?   c                   (    e Zd Z fdZd Zd ZdS )>Test_Assertions.test_assertRaises_frames_survival.<locals>.Fooc                 z                 }t          j        |          	 t          # t          $ r t          w xY wr'   )weakrefrefOSErrorr2   )r   ar?   wrs     r   foozBTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.fooo   sF    ACC[^^%!M % % %$$%s   ( :c                 F    |                      t          | j                   d S r'   r   r2   rH   r   s    r   test_functionalzNTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_functionalx   s     !!*dh77777r   c                     |                      t                    5  |                                  d d d            d S # 1 swxY w Y   d S r'   rJ   r   s    r   	test_withzHTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_with{   s    &&z22  HHJJJ                 s   =AAN)r<   r=   r>   rH   rK   rM   )r?   rG   s   r   FoorA   m   sQ        % % % % % %8 8 8    r   rN   rK   rM   )unittestTestCaserunr   assertIsNone)r   rN   r?   rG   s     @@r   !test_assertRaises_frames_survivalz1Test_Assertions.test_assertRaises_frames_survivalf   s    	 	 	 	 	 	 	 		 	 	 	 	 	 	 	(# 	 	 	$ 	""$$$""$$K""$$r   c                     |                      dd           	 |                      ddd           |                     d           d S # | j        $ r,}|                     d|j        d                    Y d }~d S d }~ww xY w)NzAla ma kotazr+zk.tMessagez"assertNotRegex should have failed.r   )assertNotRegexr/   r   r0   args)r   r)   s     r   testAssertNotRegexz"Test_Assertions.testAssertNotRegex   s    M5111	<vyAAA II:;;;;; $ 	0 	0 	0MM)QVAY/////////	0s   A 
A<!A77A<N)r<   r=   r>   r   r$   r8   rS   rX   r(   r   r   r   r   	   sg        6 6 6.G G G6(J (J (JT     @< < < < <r   r   c                       e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d"S )#TestLongMessagec                       G  fddt           j                  } G  fddt           j                  } |d           _         |d           _        d S )Nc                   (    e Zd ZdZ j        Zd ZdS )0TestLongMessage.setUp.<locals>.TestableTestFalseFc                     d S r'   r(   r   s    r   testTestz9TestLongMessage.setUp.<locals>.TestableTestFalse.testTest       r   Nr<   r=   r>   longMessager   r_   r   s   r   TestableTestFalser]      s2        K#4    r   rc   c                   (    e Zd ZdZ j        Zd ZdS )/TestLongMessage.setUp.<locals>.TestableTestTrueTc                     d S r'   r(   r   s    r   r_   z8TestLongMessage.setUp.<locals>.TestableTestTrue.testTest   r`   r   Nra   r   s   r   TestableTestTruere      s2        K#4    r   rg   r_   )rO   rP   testableTruetestableFalse)r   rc   rg   s   `  r   setUpzTestLongMessage.setUp   s    	 	 	 	 	 	 	 1 	 	 		 	 	 	 	 	 	x0 	 	 	 -,Z88..z::r   c                 N    |                      t          j        j                   d S r'   )
assertTruerO   rP   rb   r   s    r   testDefaultzTestLongMessage.testDefault   s     )566666r   c                    |                      | j                            d d          d           |                      | j                            dd          d           |                      | j                            d d          d           |                      | j                            dd          d           | j                            t	                      d           d S )NrH   barz	bar : foo)assertEqualri   _formatMessagerh   objectr   s    r   test_formatMsgzTestLongMessage.test_formatMsg   s    +::4GGOOO+::5%HH%PPP*99$FFNNN*99%GGUUU 	((599999r   c                     d                     d t          d          D                       }| j                            |d           d S )N c              3   4   K   | ]}t          |          V  d S r'   )chr).0is     r   	<genexpr>zCTestLongMessage.test_formatMessage_unicode_error.<locals>.<genexpr>   s(      11c!ff111111r      u   �)joinrangerh   rq   )r   ones     r    test_formatMessage_unicode_errorz0TestLongMessage.test_formatMessage_unicode_error   sG    gg11eCjj11111((h77777r   c                      	  fd}t          |          D ]Y\  }} ||          }i }|dz  }	|	rddi}                      j        |          5   ||i | d d d            n# 1 swxY w Y   Zd S )Nc                 R    | dk     }|rj         }nj        }t          |          S )Nr   )ri   rh   getattr)ry   useTestableFalsetest
methodNamer   s      r   	getMethodz1TestLongMessage.assertMessages.<locals>.getMethod   s7     !A ))(4,,,r   r   msgoops)expected_regex)	enumerateassertRaisesRegexr   )
r   r   rW   errorsr   ry   r   
testMethodkwargswithMsgs
   ``        r   assertMessageszTestLongMessage.assertMessages   s   		- 	- 	- 	- 	- 	- "+6!2!2 		, 		,A~"1JF!eG )''(=7E ( G G , ,
D+F+++, , , , , , , , , , , , , , ,		, 		,s   	A''A+	.A+	c                 8    |                      ddg d           d S )Nrl   )F)^False is not true$^oops$r   z^False is not true : oops$r   r   s    r   testAssertTruezTestLongMessage.testAssertTrue   s7    L(; ; ;	< 	< 	< 	< 	<r   c                 8    |                      ddg d           d S )NassertFalse)T)^True is not false$r   r   z^True is not false : oops$r   r   s    r   testAssertFalsezTestLongMessage.testAssertFalse   s7    M7; ; ;	< 	< 	< 	< 	<r   c                 8    |                      ddg d           d S )NassertNotEqualr   r   )^1 == 1$r   r   z^1 == 1 : oops$r   r   s    r   testNotEqualzTestLongMessage.testNotEqual   s8    ,f0 0 0	1 	1 	1 	1 	1r   c                 8    |                      ddg d           d S )Nr   r   r   ))^1 != 2 within 7 places \(1 difference\)$r   r   z0^1 != 2 within 7 places \(1 difference\) : oops$r   r   s    r   testAlmostEqualzTestLongMessage.testAlmostEqual   s@    B B B	C 	C 	C 	C 	Cr   c                 8    |                      ddg d           d S )Nr   r   )^1 == 1 within 7 places$r   r   z^1 == 1 within 7 places : oops$r   r   s    r   testNotAlmostEqualz"TestLongMessage.testNotAlmostEqual   s@    2F\ \ \	] 	] 	] 	] 	]r   c                 8    |                      ddg d           d S )N_baseAssertEqualr   )^1 != 2$r   r   z^1 != 2 : oops$r   r   s    r   test_baseAssertEqualz$TestLongMessage.test_baseAssertEqual   s7    .QQQ	S 	S 	S 	S 	Sr   c                 >    |                      dg d gfg d           d S )NassertSequenceEqual)\+ \[None\]$r   r   z\+ \[None\] : oops$r   r   s    r   testAssertSequenceEqualz'TestLongMessage.testAssertSequenceEqual   s@     	1B<5 5 5	6 	6 	6 	6 	6r   c                 p    |                      dt                      t          d g          fg d           d S )NassertSetEqual)None$r   r   zNone : oops$)r   setr   s    r   testAssertSetEqualz"TestLongMessage.testAssertSetEqual   sI    ,suuc4&kk.B- - -	. 	. 	. 	. 	.r   c                 <    |                      dd g fg d           d S )Nr0   )^None not found in \[\]$r   r   z^None not found in \[\] : oops$r   r   s    r   testAssertInzTestLongMessage.testAssertIn   sC    Jr
A A A	B 	B 	B 	B 	Br   c                 >    |                      dd d gfg d           d S )NassertNotIn)%^None unexpectedly found in \[None\]$r   r   z,^None unexpectedly found in \[None\] : oops$r   r   s    r   testAssertNotInzTestLongMessage.testAssertNotIn  sE    MD4&>N N N	O 	O 	O 	O 	Or   c                 @    |                      di ddifg d           d S )NassertDictEqualr+   value)\+ \{'key': 'value'\}$r   r   z\+ \{'key': 'value'\} : oops$r   r   s    r   testAssertDictEqualz#TestLongMessage.testAssertDictEqual  sG    -UG4D/E? ? ?	@ 	@ 	@ 	@ 	@r   c                     t          j                    5  t          j        dt                     |                     dddii fg d           d d d            d S # 1 swxY w Y   d S )NignoreassertDictContainsSubsetr+   r   )^Missing: 'key'$r   r   z^Missing: 'key' : oops$)warningscatch_warningssimplefilterDeprecationWarningr   r   s    r   testAssertDictContainsSubsetz,TestLongMessage.testAssertDictContainsSubset  s    $&& 	= 	=!(,>??? :eW=Mr<R!< !< !<= = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   8AA Ac                 8    |                      ddg d           d S )NassertMultiLineEqual)ru   rH   )\+ foo$r   r   z\+ foo : oops$r   r   s    r   testAssertMultiLineEqualz(TestLongMessage.testAssertMultiLineEqual  s8    2K0 0 0	1 	1 	1 	1 	1r   c                 8    |                      ddg d           d S )N
assertLessr   r   )^2 not less than 1$r   r   z^2 not less than 1 : oops$r   r   s    r   testAssertLesszTestLongMessage.testAssertLess!  s?    L&R R R	S 	S 	S 	S 	Sr   c                 8    |                      ddg d           d S )NassertLessEqualr   )^2 not less than or equal to 1$r   r   z&^2 not less than or equal to 1 : oops$r   r   s    r   testAssertLessEqualz#TestLongMessage.testAssertLessEqual&  s@    -vG G G	H 	H 	H 	H 	Hr   c                 8    |                      ddg d           d S )NassertGreaterr   )^1 not greater than 2$r   r   z^1 not greater than 2 : oops$r   r   s    r   testAssertGreaterz!TestLongMessage.testAssertGreater,  s7    OV> > >	? 	? 	? 	? 	?r   c                 8    |                      ddg d           d S )NassertGreaterEqualr   )"^1 not greater than or equal to 2$r   r   z)^1 not greater than or equal to 2 : oops$r   r   s    r   testAssertGreaterEqualz&TestLongMessage.testAssertGreaterEqual2  s@    0&J J J	K 	K 	K 	K 	Kr   c                 8    |                      ddg d           d S )NrR   )znot None)^'not None' is not None$r   r   z^'not None' is not None : oops$r   r   s    r   testAssertIsNonez TestLongMessage.testAssertIsNone8  s?    NM@ @ @	A 	A 	A 	A 	Ar   c                 8    |                      ddg d           d S )NassertIsNotNoner'   )^unexpectedly None$r   r   z^unexpectedly None : oops$r   r   s    r   testAssertIsNotNonez#TestLongMessage.testAssertIsNotNone>  s8    -w; ; ;	< 	< 	< 	< 	<r   c                 8    |                      ddg d           d S )Nr4   NrH   )^None is not 'foo'$r   r   z^None is not 'foo' : oops$r   r   s    r   testAssertIszTestLongMessage.testAssertIsD  s7    J; ; ;	< 	< 	< 	< 	<r   c                 8    |                      ddg d           d S )NassertIsNot)NN)^unexpectedly identical: None$r   r   z%^unexpectedly identical: None : oops$r   r   s    r   testAssertIsNotzTestLongMessage.testAssertIsNotJ  s?    M<F F F	G 	G 	G 	G 	Gr   c                 8    |                      ddg d           d S )NassertRegex)rH   ro   )^Regex didn't match:r   r   z!^Regex didn't match: (.*) : oops$r   r   s    r   testAssertRegexzTestLongMessage.testAssertRegexP  s?    M>B B B	C 	C 	C 	C 	Cr   c                 8    |                      ddg d           d S )NrV   )rH   rH   )^Regex matched:r   r   z^Regex matched: (.*) : oops$r   r   s    r   rX   z"TestLongMessage.testAssertNotRegexW  s8    ,n= = =	> 	> 	> 	> 	>r   c                 T   	 t          | j        | j        fi ddif          }t          ||          D ]u\  \  }}}t	          ||          }	|                     |j        |          5   |	|i |5 }
 |             d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   vd S )Nr   r   )r   ri   rh   zipr   r   r   )r   r   rW   funcr   pclsr   errmethodr6   s              r   assertMessagesCMz TestLongMessage.assertMessagesCM_  sK   		 T'):;%)+ +"%a.. 	 	MS&3S*--F''(<cBB  VT,V,, DFFF                            	 	s6   %	B.B9BB		BB	BB 	#B 	c                 H    |                      dt          fd g d           d S )Nr   c                      d S r'   r(   r(   r   r   r-   z2TestLongMessage.testAssertRaises.<locals>.<lambda>s  s    D r   ^TypeError not raised$r   r   z^TypeError not raised : oops$r   r   r   s    r   testAssertRaisesz TestLongMessage.testAssertRaisesr  sE    nylLL@ @ @	A 	A 	A 	A 	Ar   c                     |                      dt          dfd g d           d }|                      dt          df|g d           d S )Nr   unused regexc                      d S r'   r(   r(   r   r   r-   z7TestLongMessage.testAssertRaisesRegex.<locals>.<lambda>{      d r   r   c                       t          d          r   )r   r(   r   r   raise_wrong_messagezBTestLongMessage.testAssertRaisesRegex.<locals>.raise_wrong_message  s    E"""r   regex^"regex" does not match "foo"$r   r  z%^"regex" does not match "foo" : oops$r   r   r  s     r   testAssertRaisesRegexz%TestLongMessage.testAssertRaisesRegexx  s    1I~3N*l@ @ @	A 	A 	A	# 	# 	#1Iw3G1H H H	I 	I 	I 	I 	Ir   c                 H    |                      dt          fd g d           d S )NassertWarnsc                      d S r'   r(   r(   r   r   r-   z1TestLongMessage.testAssertWarns.<locals>.<lambda>  s    T r   ^UserWarning not triggered$r   r  z"^UserWarning not triggered : oops$r   UserWarningr   s    r   testAssertWarnszTestLongMessage.testAssertWarns  sE    mk^\\E E E	F 	F 	F 	F 	Fr   c                     |                      dt          dfd g d           d }|                      dt          df|g d           d S )NassertWarnsRegexr  c                      d S r'   r(   r(   r   r   r-   z6TestLongMessage.testAssertWarnsRegex.<locals>.<lambda>  r  r   r  c                  .    t          j        d           d S r   )r   warnr(   r   r   r  zATestLongMessage.testAssertWarnsRegex.<locals>.raise_wrong_message  s    M%     r   r  r  r  r	  s     r   testAssertWarnsRegexz$TestLongMessage.testAssertWarnsRegex  s    0;2O*lE E E	F 	F 	F	! 	! 	!0;2H1H H H	I 	I 	I 	I 	Ir   N)$r<   r=   r>   rj   rm   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rX   r   r   r
  r  r  r(   r   r   rZ   rZ      s:       %; ; ;$7 7 7: : :8 8 8
, , ,8< < <
< < <
1 1 1
C C C] ] ]
S S S6 6 6. . .
B B BO O O@ @ @= = =1 1 1S S S
H H H? ? ?K K KA A A< < << < <G G GC C C> > >  &A A AI I I F F FI I I I Ir   rZ   __main__)r   r   rC   rO   test.supportr   	itertoolsr   rP   r   rZ   r<   mainr(   r   r   <module>r     s        # # # # # #      D< D< D< D< D<h' D< D< D<NLI LI LI LI LIh' LI LI LI^ zHMOOOOO r   