Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/unittest/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/unittest/test/__pycache__/test_assertions.cpython-38.opt-2.pyc

U

i�f�B�@sdddlZddlZddlZddlZddlmZGdd�dej�ZGdd�dej�Ze	dkr`e�
�dS)�N)�productc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�Test_AssertionscCs�|�dd�|�dd�|�|j|jdd�|�|j|jdd�|jdddd�|j|j|jdddd�|jdddd�|jdddd�|j|j|jdddd�|j|j|jdddd�|�td	�td	��|�|j|jtd	�td	��dS)
Ng�1��?��?g����?皙�����?r)�places�y�������?�������?�inf)�assertAlmostEqual�assertNotAlmostEqual�assertRaises�failureException�float��self�r�B/opt/alt/python38/lib64/python3.8/unittest/test/test_assertions.py�test_AlmostEqual	sL������z Test_Assertions.test_AlmostEqualcCs|jdddd�|jdddd�|jdddd�|jdddd�|jdddd�|j|j|jdddd�|j|j|jdddd�|j|j|jdddd�|jt|jddddd�|jt|jddddd�tj��}|tjdd	�}|j||tjd
d	�d�|j||tjdd	�d�dS)Nrrg�?)�deltag�������?�)rr�
)Zseconds��)r	r
rr�	TypeError�datetimeZnowZ	timedelta)r�first�secondrrr�test_AmostEqualWithDelta sP���
�
�

�
�z(Test_Assertions.test_AmostEqualWithDeltacCs�dd�}|�t|t�|�t|td��z|�tdd��Wn4|jk
rp}z|�dt|��W5d}~XYnX|�d�z|�t|t�Wntk
r�YnX|�d�|�t��8}zt�Wn(tk
r�}z
|}�W5d}~XYnXW5QRX|�|j	|�|�t��td��W5QRXz|�t��W5QRXWn6|jk
�rr}z|�dt|��W5d}~XYnX|�d�z|�t��
t�W5QRXWntk
�r�YnX|�d�dS)	NcSs|�dS�Nr)�errr�_raise<sz1Test_Assertions.test_assertRaises.<locals>._raise�keycSsdSrrrrrr�<lambda>A�z3Test_Assertions.test_assertRaises.<locals>.<lambda>zKeyError not raisedzassertRaises() didn't failz0assertRaises() didn't let exception pass through)
r�KeyErrorr�assertIn�str�fail�
ValueError�	Exception�assertIsZ	exception)rrr�cm�excrrr�test_assertRaises;sD"

"
z!Test_Assertions.test_assertRaisescs^Gdd�d��d�G��fdd�dtj�}|d���|����|d���|����dS)Nc@seZdZdS)z<Test_Assertions.test_assertRaises_frames_survival.<locals>.AN)�__name__�
__module__�__qualname__rrrr�Ahsr0cs*eZdZ��fdd�Zdd�Zdd�ZdS)z>Test_Assertions.test_assertRaises_frames_survival.<locals>.Foocs6��}t�|��zt�Wntk
r0t�YnXdSr)�weakref�ref�OSErrorr')r�a�r0Zwrrr�foons
zBTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.foocSs|�t|j�dSr�rr'r6rrrr�test_functionalwszNTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_functionalc	Ss"|�t��|��W5QRXdSrr7rrrr�	test_withzszHTest_Assertions.test_assertRaises_frames_survival.<locals>.Foo.test_withN)r-r.r/r6r8r9rr5rr�Fools	r:r8r9)�unittest�TestCase�run�assertIsNone)rr:rr5r�!test_assertRaises_frames_survivalesz1Test_Assertions.test_assertRaises_frames_survivalc
Csd|�dd�z|�ddd�Wn6|jk
rT}z|�d|jd�W5d}~XYnX|�d�dS)NzAla ma kotazr+zk.tZMessagerz"assertNotRegex should have failed.)�assertNotRegexrr$�argsr&)rrrrr�testAssertNotRegex�s$z"Test_Assertions.testAssertNotRegexN)r-r.r/rrr,r?rBrrrrrs
*rc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCS)D�TestLongMessagecsDG�fdd�dtj�}G�fdd�dtj�}|d��_|d��_dS)NcseZdZdZ�jZdd�ZdS)z0TestLongMessage.setUp.<locals>.TestableTestFalseFcSsdSrrrrrr�testTest�sz9TestLongMessage.setUp.<locals>.TestableTestFalse.testTestN�r-r.r/�longMessagerrDrrrr�TestableTestFalse�srGcseZdZdZ�jZdd�ZdS)z/TestLongMessage.setUp.<locals>.TestableTestTrueTcSsdSrrrrrrrD�sz8TestLongMessage.setUp.<locals>.TestableTestTrue.testTestNrErrrr�TestableTestTrue�srHrD)r;r<�testableTrue�
testableFalse)rrGrHrrr�setUp�s
zTestLongMessage.setUpcCs|�tjj�dSr)�
assertTruer;r<rFrrrr�testDefault�szTestLongMessage.testDefaultcCsl|�|j�dd�d�|�|j�dd�d�|�|j�dd�d�|�|j�dd�d�|j�t�d�dS)Nr6�barz	bar : foo)ZassertEqualrJ�_formatMessagerI�objectrrrr�test_formatMsg�s
zTestLongMessage.test_formatMsgcCs*d�dd�td�D��}|j�|d�dS)N�css|]}t|�VqdSr)�chr)�.0�irrr�	<genexpr>�szCTestLongMessage.test_formatMessage_unicode_error.<locals>.<genexpr>�u�)�join�rangerIrO)rZonerrr� test_formatMessage_unicode_error�sz0TestLongMessage.test_formatMessage_unicode_errorc

sj��fdd�}t|�D]N\}}||�}i}|d}	|	r>ddi}�j�j|d��|||�W5QRXqdS)Ncs$|dk}|r�j}n�j}t|��S)Nr)rJrI�getattr)rUZuseTestableFalseZtest��
methodNamerrr�	getMethod�s
z1TestLongMessage.assertMessages.<locals>.getMethodr�msg�oops)�expected_regex)�	enumerate�assertRaisesRegexr)
rr]rA�errorsr^rUraZ
testMethod�kwargsZwithMsgrr\r�assertMessages�s	�zTestLongMessage.assertMessagescCs|�ddddddg�dS)NrL)Fz^False is not true$�^oops$z^False is not true : oops$�rfrrrr�testAssertTrue�s
��zTestLongMessage.testAssertTruecCs|�ddddddg�dS)NZassertFalse)Tz^True is not false$rgz^True is not false : oops$rhrrrr�testAssertFalse�s
��zTestLongMessage.testAssertFalsecCs|�ddddddg�dS)NZassertNotEqual�rrz^1 == 1$rgz^1 == 1 : oops$rhrrrr�testNotEqual�s
��zTestLongMessage.testNotEqualcCs|�ddddddg�dS)Nr	�rrz)^1 != 2 within 7 places \(1 difference\)$rgz0^1 != 2 within 7 places \(1 difference\) : oops$rhrrrr�testAlmostEqual�s��zTestLongMessage.testAlmostEqualcCs|�ddddddg�dS)Nr
rkz^1 == 1 within 7 places$rgz^1 == 1 within 7 places : oops$rhrrrr�testNotAlmostEqual�s��z"TestLongMessage.testNotAlmostEqualcCs|�ddddddg�dS)NZ_baseAssertEqualrmz^1 != 2$rgz^1 != 2 : oops$rhrrrr�test_baseAssertEqual�s
�z$TestLongMessage.test_baseAssertEqualcCs |�dgdgfddddg�dS)NZassertSequenceEqualz\+ \[None\]$rgz\+ \[None\] : oops$rhrrrr�testAssertSequenceEqual�s
��z'TestLongMessage.testAssertSequenceEqualcCs&|�dt�tdg�fddddg�dS)NZassertSetEqualzNone$rgzNone : oops$)rf�setrrrr�testAssertSetEqual�s
��z"TestLongMessage.testAssertSetEqualcCs|�ddgfddddg�dS)Nr$z^None not found in \[\]$rgz^None not found in \[\] : oops$rhrrrr�testAssertIn�s��zTestLongMessage.testAssertIncCs |�dddgfddddg�dS)NZassertNotInz%^None unexpectedly found in \[None\]$rgz,^None unexpectedly found in \[None\] : oops$rhrrrr�testAssertNotIns��zTestLongMessage.testAssertNotIncCs"|�diddifddddg�dS)NZassertDictEqualr �valuez\+ \{'key': 'value'\}$rgz\+ \{'key': 'value'\} : oops$rhrrrr�testAssertDictEqual	s��z#TestLongMessage.testAssertDictEqualc	CsBt���0t�dt�|�dddiifddddg�W5QRXdS)N�ignoreZassertDictContainsSubsetr rvz^Missing: 'key'$rgz^Missing: 'key' : oops$)�warnings�catch_warnings�simplefilter�DeprecationWarningrfrrrr�testAssertDictContainsSubsets
��z,TestLongMessage.testAssertDictContainsSubsetcCs|�ddddddg�dS)NZassertMultiLineEqual)rRr6z\+ foo$rgz\+ foo : oops$rhrrrr�testAssertMultiLineEquals��z(TestLongMessage.testAssertMultiLineEqualcCs|�ddddddg�dS)NZ
assertLess�rrz^2 not less than 1$rgz^2 not less than 1 : oops$rhrrrr�testAssertLesss��zTestLongMessage.testAssertLesscCs|�ddddddg�dS)NZassertLessEqualrz^2 not less than or equal to 1$rgz&^2 not less than or equal to 1 : oops$rhrrrr�testAssertLessEqual#s��z#TestLongMessage.testAssertLessEqualcCs|�ddddddg�dS)NZ
assertGreaterrmz^1 not greater than 2$rgz^1 not greater than 2 : oops$rhrrrr�testAssertGreater)s��z!TestLongMessage.testAssertGreatercCs|�ddddddg�dS)NZassertGreaterEqualrmz"^1 not greater than or equal to 2$rgz)^1 not greater than or equal to 2 : oops$rhrrrr�testAssertGreaterEqual/s��z&TestLongMessage.testAssertGreaterEqualcCs|�ddddddg�dS)Nr>)znot Nonez^'not None' is not None$rgz^'not None' is not None : oops$rhrrrr�testAssertIsNone5s��z TestLongMessage.testAssertIsNonecCs|�ddddddg�dS)NZassertIsNotNonerz^unexpectedly None$rgz^unexpectedly None : oops$rhrrrr�testAssertIsNotNone;s��z#TestLongMessage.testAssertIsNotNonecCs|�ddddddg�dS)Nr)�Nr6z^None is not 'foo'$rgz^None is not 'foo' : oops$rhrrrr�testAssertIsAs��zTestLongMessage.testAssertIscCs|�ddddddg�dS)NZassertIsNot)NNz^unexpectedly identical: None$rgz%^unexpectedly identical: None : oops$rhrrrr�testAssertIsNotGs��zTestLongMessage.testAssertIsNotcCs|�ddddddg�dS)NZassertRegex)r6rNz^Regex didn't match:rgz!^Regex didn't match: (.*) : oops$rhrrrr�testAssertRegexMs��zTestLongMessage.testAssertRegexcCs|�ddddddg�dS)Nr@)r6r6z^Regex matched:rgz^Regex matched: (.*) : oops$rhrrrrrBTs��z"TestLongMessage.testAssertNotRegexcCsvt|j|jfiddif�}t||�D]L\\}}}t||�}	|�|j|��"|	||��}
|�W5QRXW5QRXq$dS)Nr_r`)rrJrI�zipr[rcr)rr]rA�funcrd�p�clsre�err�methodr*rrr�assertMessagesCM\s
�
z TestLongMessage.assertMessagesCMc	Cs"|�dtfdd�ddddg�dS)NrcSsdSrrrrrrr!pr"z2TestLongMessage.testAssertRaises.<locals>.<lambda>�^TypeError not raised$rg�^TypeError not raised : oops$�r�rrrrr�testAssertRaisesos��z TestLongMessage.testAssertRaisesc	CsH|�dtdfdd�ddddg�dd	�}|�dtd
f|ddddg�dS)
Nrc�unused regexcSsdSrrrrrrr!xr"z7TestLongMessage.testAssertRaisesRegex.<locals>.<lambda>r�rgr�cSstd��dSr�)rrrrr�raise_wrong_message}szBTestLongMessage.testAssertRaisesRegex.<locals>.raise_wrong_message�regex�^"regex" does not match "foo"$�%^"regex" does not match "foo" : oops$r��rr�rrr�testAssertRaisesRegexus����z%TestLongMessage.testAssertRaisesRegexc	Cs"|�dtfdd�ddddg�dS)NZassertWarnscSsdSrrrrrrr!�r"z1TestLongMessage.testAssertWarns.<locals>.<lambda>�^UserWarning not triggered$rg�"^UserWarning not triggered : oops$�r��UserWarningrrrr�testAssertWarns�s��zTestLongMessage.testAssertWarnsc	CsH|�dtdfdd�ddddg�dd	�}|�dtd
f|ddddg�dS)
NZassertWarnsRegexr�cSsdSrrrrrrr!�r"z6TestLongMessage.testAssertWarnsRegex.<locals>.<lambda>r�rgr�cSst�d�dSr�)ry�warnrrrrr��szATestLongMessage.testAssertWarnsRegex.<locals>.raise_wrong_messager�r�r�r�r�rrr�testAssertWarnsRegex�s����z$TestLongMessage.testAssertWarnsRegexN)$r-r.r/rKrMrQrZrfrirjrlrnrorprqrsrtrurwr}r~r�r�r�r�r�r�r�r�r�rBr�r�r�r�r�rrrrrC�sB
	rC�__main__)rryr1r;�	itertoolsrr<rrCr-�mainrrrr�<module>s