
    4hhsC                         S SK r S SKrS SKrS SKrS SKJr  S SKJr   " S S\R                  5      r	 " S S\R                  5      r
\S:X  a  \R                  " 5         gg)	    N)
gc_collect)productc                   2    \ rS rSrS rS rS rS rS rSr	g)	Test_Assertions	   c                    U R                  SS5        U R                  SS5        U R                  U R                  U R                   SS5        U R                  U R                  U R                  SS5        U R                  SSSS9  U R                  U R                  U R                   SSSS9  U R                  SSSS9  U R                  SSSS9  U R                  U R                  U R                   SSSS9  U R                  U R                  U R                  SSSS9  U R                  [	        S	5      [	        S	5      5        U R                  U R                  U R                  [	        S	5      [	        S	5      5        g )
Ng1  ?      ?g  ?皙?r   )places   y??inf)assertAlmostEqualassertNotAlmostEqualassertRaisesfailureExceptionfloatselfs    K/opt/python-3.13.8/usr/lib/python3.13/test/test_unittest/test_assertions.pytest_AlmostEqual Test_Assertions.test_AlmostEqual
   ss   z3/!!)S1$//00)S	B$//33Z	F 	sC2$//00#s1 	 	F 	q&3!!!VA!6$//00!VA 	 	G$//33Qq 	 	J 	uU|U5\:$//1J1J,e	6    c           	         U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  U R                  U R                  U R                  SSSS9  U R                  U R                  U R                   SSSS9  U R                  U R                  U R                  SSSS9  U R                  [        U R                   SSSSS9  U R                  [        U R                  SSSSS9  [
        R
                  R                  5       nU[
        R                  " SS	9-   nU R                  X[
        R                  " S
S	9S9  U R                  X[
        R                  " SS	9S9  g )Nr
   r	   g      ?)deltag?   )r   r   
   )seconds      )r   r   r   r   	TypeErrordatetimenow	timedelta)r   firstseconds      r   test_AmostEqualWithDelta(Test_Assertions.test_AmostEqualWithDelta!   s   sCs3sCs3!!#s$!7!!#s$!7sCs3$//1J1Js# 	 	/ 	$//1G1Gs$ 	 	0$//1J1Js# 	 	/ 	)T%;%;s1A 	 	7)T%>%>s1A 	 	7 !!%%'++B77u%-%7%7%C 	 	E!!%(0(:(:1(E 	" 	Gr   c                 v   S nU R                  [        U[        5        U R                  [        U[        S5      5         U R                  [        S 5        U R                  S5         U R                  [        U[        5        U R                  S5        U R                  [        5       n [        e! U R                   a%  nU R	                  S[        U5      5         S nANzS nAff = f! [         a     Naf = f! [         a  nUne S nAff = f! , (       d  f       O= fU R                  WR                  W5        U R                  [        5         [        S5      e! , (       d  f       O= f U R                  [        5          S S S 5        O! , (       d  f       O= fU R                  S5        O8! U R                   a%  nU R	                  S[        U5      5         S nAOS nAff = f U R                  [        5         [        e! , (       d  f       O= f U R                  S5        g ! [         a     g f = f)Nc                     U eN )es    r   _raise1Test_Assertions.test_assertRaises.<locals>._raise=   s    Gr   keyc                      g r*   r+   r+   r   r   <lambda>3Test_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_assertRaises!Test_Assertions.test_assertRaises<   s   	(FH5(FHUO<	4h5 II23	Jh
; IIHIx(B $$ 	9MM/Q88	9  		   )( 	bllC(x(5/! )(	4""8, -,,
 II23 $$ 	9MM/Q88	9	J""8,   -,,
 IIHI  		s    B2 )C* *D,C:2C'C""C'*
C76C7:
DDDD
DE
E+/F2 F	F2 
FF2 2G'G""G'+H+  H
HH+ +
H87H8c                 2  ^^  " S S5      mS m " UU4S jS[         R                  5      nU" S5      R                  5         [        5         U R	                  T" 5       5        U" S5      R                  5         [        5         U R	                  T" 5       5        g )Nc                       \ rS rSrSrg)<Test_Assertions.test_assertRaises_frames_survival.<locals>.Ai   r+   N)__name__
__module____qualname____firstlineno____static_attributes__r+   r   r   ArA   i   s    r   rH   c                   0   > \ rS rSrU U4S jrS rS rSrg)>Test_Assertions.test_assertRaises_frames_survival.<locals>.Foom   c                 t   > T" 5       n[         R                  " U5      m [        e! [         a    [        ef = fr*   )weakrefrefOSErrorr7   )r   arH   wrs     r   fooBTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.fooo   s6    C[[^%!M %$$%s   & 7c                 D    U R                  [        U R                  5        g r*   r   r7   rR   r   s    r   test_functionalNTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_functionalx   s    !!*dhh7r   c                     U R                  [        5         U R                  5         S S S 5        g ! , (       d  f       g = fr*   rU   r   s    r   	test_withHTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_with{   s%    &&z2HHJ 322s   0
>r+   N)rC   rD   rE   rF   rR   rV   rY   rG   )rH   rQ   s   r   FoorJ   m   s    %8r   r[   rV   rY   )unittestTestCaserunr   assertIsNone)r   r[   rH   rQ   s     @@r   !test_assertRaises_frames_survival1Test_Assertions.test_assertRaises_frames_survivalf   sx    	 		 	(## 	$ 	""$"$K"$r   c                     U R                  SS5         U R                  SSS5        U R                  S5        g ! U R                   a)  nU R                  SUR                  S   5         S nAg S nAff = f)NzAla ma kotazr+zk.tMessagez"assertNotRegex should have failed.r   )assertNotRegexr4   r   r5   args)r   r,   s     r   testAssertNotRegex"Test_Assertions.testAssertNotRegex   si    M51	<vyA II:; $$ 	0MM)QVVAY//	0s   9 A2	A--A2r+   N)
rC   rD   rE   rF   r   r&   r=   r`   rf   rG   r+   r   r   r   r   	   s    6.G6(JT @<r   r   c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$r&g%)&TestLongMessage   zTest that the individual asserts honour longMessage.
This actually tests all the message behaviour for
asserts that use longMessage.c                    ^   " U 4S jS[         R                  5      n " U 4S jS[         R                  5      nU" S5      T l        U" S5      T l        g )Nc                   :   > \ rS rSrSr Y R
                  rS rSrg)0TestLongMessage.setUp.<locals>.TestableTestFalse   Fc                     g r*   r+   r   s    r   testTest9TestLongMessage.setUp.<locals>.TestableTestFalse.testTest       r   r+   NrC   rD   rE   rF   longMessager   rp   rG   r   s   r   TestableTestFalserm      s    K#44r   ru   c                   :   > \ rS rSrSr Y R
                  rS rSrg)/TestLongMessage.setUp.<locals>.TestableTestTrue   Tc                     g r*   r+   r   s    r   rp   8TestLongMessage.setUp.<locals>.TestableTestTrue.testTest   rr   r   r+   Nrs   r   s   r   TestableTestTruerw      s    K#44r   r{   rp   )r\   r]   testableTruetestableFalse)r   ru   r{   s   `  r   setUpTestLongMessage.setUp   sC    	 1 1 		x00 	 -Z8.z:r   c                 V    U R                  [        R                  R                  5        g r*   )
assertTruer\   r]   rt   r   s    r   testDefaultTestLongMessage.testDefault   s    ))556r   c                    U R                  U R                  R                  S S5      S5        U R                  U R                  R                  SS5      S5        U R                  U R                  R                  S S5      S5        U R                  U R                  R                  SS5      S5        U R                  R                  [	        5       S5        g )NrR   barz	bar : foo)assertEqualr}   _formatMessager|   objectr   s    r   test_formatMsgTestLongMessage.test_formatMsg   s    ++::4GO++::5%H%P**99$FN**99%GU 	((59r   c                 ~    SR                  S [        S5       5       5      nU R                  R                  US5        g )N c              3   8   #    U  H  n[        U5      v   M     g 7fr*   )chr).0is     r   	<genexpr>CTestLongMessage.test_formatMessage_unicode_error.<locals>.<genexpr>   s     1jc!ffjs      u   �)joinranger|   r   )r   ones     r    test_formatMessage_unicode_error0TestLongMessage.test_formatMessage_unicode_error   s0    gg1eCj11((h7r   c                    ^ ^ UU 4S jn[        U5       HJ  u  pVU" U5      n0 nUS-  n	U	(       a  SS0nT R                  T R                  US9   U" U0 UD6  SSS5        ML     g! , (       d  f       M^  = f)a'  
Check that methodName(*args) raises the correct error messages.
errors should be a list of 4 regex that match the error when:
  1) longMessage = False and no msg passed;
  2) longMessage = False and msg passed;
  3) longMessage = True and no msg passed;
  4) longMessage = True and msg passed;
c                 f   > U S:  nU(       a  TR                   nOTR                  n[        UT5      $ )Nr   )r}   r|   getattr)r   useTestableFalsetest
methodNamer   s      r   	getMethod1TestLongMessage.assertMessages.<locals>.getMethod   s3     !A))((4,,r   r   msgoops)expected_regexN)	enumerateassertRaisesRegexr   )
r   r   re   errorsr   r   r   
testMethodkwargswithMsgs
   ``        r   assertMessagesTestLongMessage.assertMessages   s    	- "+6!2A"1JF!eG''(=(=7E ( GD+F+G G "3G Gs   	A$$
A3	c                 .    U R                  SS/ SQ5        g )Nr   )F)^False is not true$^oops$r   z^False is not true : oops$r   r   s    r   testAssertTrueTestLongMessage.testAssertTrue   s    L(;	<r   c                 .    U R                  SS/ SQ5        g )NassertFalse)T)^True is not false$r   r   z^True is not false : oops$r   r   s    r   testAssertFalseTestLongMessage.testAssertFalse   s    M7;	<r   c                 .    U R                  SS/ SQ5        g )NassertNotEqualr   r   )^1 == 1$r   r   z^1 == 1 : oops$r   r   s    r   testNotEqualTestLongMessage.testNotEqual   s    ,f0	1r   c                 .    U R                  SS/ SQ5        g )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   testAlmostEqualTestLongMessage.testAlmostEqual   s    B	Cr   c                 .    U R                  SS/ SQ5        g )Nr   r   )^1 == 1 within 7 places$r   r   z^1 == 1 within 7 places : oops$r   r   s    r   testNotAlmostEqual"TestLongMessage.testNotAlmostEqual   s    2F\	]r   c                 .    U R                  SS/ SQ5        g )N_baseAssertEqualr   )^1 != 2$r   r   z^1 != 2 : oops$r   r   s    r   test_baseAssertEqual$TestLongMessage.test_baseAssertEqual   s    .Q	Sr   c                 4    U R                  S/ S /4/ SQ5        g )NassertSequenceEqual)\+ \[None\]$r   r   z\+ \[None\] : oops$r   r   s    r   testAssertSequenceEqual'TestLongMessage.testAssertSequenceEqual   s"     	1B<5	6r   c                 V    U R                  S[        5       [        S /5      4/ SQ5        g )NassertSetEqual)None$r   r   zNone : oops$)r   setr   s    r   testAssertSetEqual"TestLongMessage.testAssertSetEqual   s'    ,suc4&k.B-	.r   c                 2    U R                  SS / 4/ SQ5        g )Nr5   )^None not found in \[\]$r   r   z^None not found in \[\] : oops$r   r   s    r   testAssertInTestLongMessage.testAssertIn   s    Jr
A	Br   c                 4    U R                  SS S /4/ SQ5        g )NassertNotIn)%^None unexpectedly found in \[None\]$r   r   z,^None unexpectedly found in \[None\] : oops$r   r   s    r   testAssertNotInTestLongMessage.testAssertNotIn  s!    MD4&>N	Or   c                 6    U R                  S0 SS04/ SQ5        g )NassertDictEqualr/   value)\+ \{'key': 'value'\}$r   r   z\+ \{'key': 'value'\} : oops$r   r   s    r   testAssertDictEqual#TestLongMessage.testAssertDictEqual  s%    -UG4D/E?	@r   c                 .    U R                  SS/ SQ5        g )NassertMultiLineEqual)r   rR   )	\+ foo\n$r   r   z\+ foo\n : oops$r   r   s    r   testAssertMultiLineEqual(TestLongMessage.testAssertMultiLineEqual  s    2K2	3r   c                 .    U R                  SS/ SQ5        g )N
assertLessr   r   )^2 not less than 1$r   r   z^2 not less than 1 : oops$r   r   s    r   testAssertLessTestLongMessage.testAssertLess  s    L&R	Sr   c                 .    U R                  SS/ SQ5        g )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   testAssertLessEqual#TestLongMessage.testAssertLessEqual  s    -vG	Hr   c                 .    U R                  SS/ SQ5        g )NassertGreaterr   )^1 not greater than 2$r   r   z^1 not greater than 2 : oops$r   r   s    r   testAssertGreater!TestLongMessage.testAssertGreater#  s    OV>	?r   c                 .    U R                  SS/ SQ5        g )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   testAssertGreaterEqual&TestLongMessage.testAssertGreaterEqual)  s    0&J	Kr   c                 .    U R                  SS/ SQ5        g )Nr_   )znot None)^'not None' is not None$r   r   z^'not None' is not None : oops$r   r   s    r   testAssertIsNone TestLongMessage.testAssertIsNone/  s    NM@	Ar   c                 .    U R                  SS/ SQ5        g )NassertIsNotNoner*   )^unexpectedly None$r   r  z^unexpectedly None : oops$r   r   s    r   testAssertIsNotNone#TestLongMessage.testAssertIsNotNone5  s    -w;	<r   c                 .    U R                  SS/ SQ5        g )Nr9   NrR   )^None is not 'foo'$r   r
  z^None is not 'foo' : oops$r   r   s    r   testAssertIsTestLongMessage.testAssertIs;  s    J;	<r   c                 .    U R                  SS/ SQ5        g )NassertIsNot)NN)^unexpectedly identical: None$r   r  z%^unexpectedly identical: None : oops$r   r   s    r   testAssertIsNotTestLongMessage.testAssertIsNotA  s    M<F	Gr   c                 .    U R                  SS/ SQ5        g )NassertRegex)rR   r   )^Regex didn't match:r   r  z!^Regex didn't match: (.*) : oops$r   r   s    r   testAssertRegexTestLongMessage.testAssertRegexG  s    M>B	Cr   c                 .    U R                  SS/ SQ5        g )Nrd   )rR   rR   )^Regex matched:r   r  z^Regex matched: (.*) : oops$r   r   s    r   rf   "TestLongMessage.testAssertNotRegexN  s    ,n=	>r   c                 T   [        U R                  U R                  40 SS045      n[        XT5       HP  u  u  pgn[	        Xa5      n	U R                  UR                  U5         U	" U0 UD6 n
U" 5         SSS5        SSS5        MR     g! , (       d  f       N= f! , (       d  f       Mu  = f)aN  
Check that the correct error messages are raised while executing:
  with method(*args):
      func()
*errors* should be a list of 4 regex that match the error when:
  1) longMessage = False and no msg passed;
  2) longMessage = False and msg passed;
  3) longMessage = True and no msg passed;
  4) longMessage = True and msg passed;
r   r   N)r   r}   r|   zipr   r   r   )r   r   re   funcr   pclsr   errmethodr;   s              r   assertMessagesCM TestLongMessage.assertMessagesCMV  s     T''):):;%)+"%a.MS3S-F''(<(<cBT,V,F - CB #1 -, CBs$   !	B*B2B
BB
B'	c                 <    U R                  S[        4S / SQ5        g )Nr   c                      g r*   r+   r+   r   r   r1   2TestLongMessage.testAssertRaises.<locals>.<lambda>j  s    Dr   ^TypeError not raised$r   r'  z^TypeError not raised : oops$r!  r    r   s    r   testAssertRaises TestLongMessage.testAssertRaisesi  s    nylL@	Ar   c                 |    U R                  S[        S4S / SQ5        S nU R                  S[        S4U/ SQ5        g )Nr   unused regexc                      g r*   r+   r+   r   r   r1   7TestLongMessage.testAssertRaisesRegex.<locals>.<lambda>r      dr   r&  c                      [        S5      er	  )r    r+   r   r   raise_wrong_messageBTestLongMessage.testAssertRaisesRegex.<locals>.raise_wrong_messagew  s    E""r   regex^"regex" does not match "foo"$r   r5  z%^"regex" does not match "foo" : oops$r(  r   r1  s     r   testAssertRaisesRegex%TestLongMessage.testAssertRaisesRegexo  sK    1I~3N*@	A	#1Iw3G1H	Ir   c                 <    U R                  S[        4S / SQ5        g )NassertWarnsc                      g r*   r+   r+   r   r   r1   1TestLongMessage.testAssertWarns.<locals>.<lambda>  s    Tr   ^UserWarning not triggered$r   r>  z"^UserWarning not triggered : oops$r!  UserWarningr   s    r   testAssertWarnsTestLongMessage.testAssertWarns  s    mk^\E	Fr   c                 @    S nU R                  S[        4U/ SQ5        g )Nc                  8    [         R                  " S[        SS9  g )Nxyzr   )
stacklevel)warningswarnFutureWarningr+   r   r   warn_future8TestLongMessage.test_assertNotWarns.<locals>.warn_future  s    MM%1=r   _assertNotWarns)^FutureWarning triggered$r   rM  z ^FutureWarning triggered : oops$)r!  rI  )r   rJ  s     r   test_assertNotWarns#TestLongMessage.test_assertNotWarns  s'    	>/-1A)C	Dr   c                 |    U R                  S[        S4S / SQ5        S nU R                  S[        S4U/ SQ5        g )NassertWarnsRegexr,  c                      g r*   r+   r+   r   r   r1   6TestLongMessage.testAssertWarnsRegex.<locals>.<lambda>  r/  r   r=  c                  0    [         R                  " S5        g r	  )rG  rH  r+   r   r   r1  ATestLongMessage.testAssertWarnsRegex.<locals>.raise_wrong_message  s    MM% r   r3  r4  r?  r6  s     r   testAssertWarnsRegex$TestLongMessage.testAssertWarnsRegex  sK    0;2O*E	F	!0;2H1H	Ir   )r}   r|   N)'rC   rD   rE   rF   __doc__r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  rf   r!  r)  r7  rA  rN  rV  rG   r+   r   r   ri   ri      s    %;$7:8
,8<
<
1
C]
S6.
BO@3S
H?KA<<GC>&AI FDIr   ri   __main__)r!   rG  rM   r\   test.supportr   	itertoolsr   r]   r   ri   rC   mainr+   r   r   <module>r]     s[        # D<h'' D<NMIh'' MI` zMMO r   