OwlCyberSecurity - MANAGER
Edit File: case.cpython-38.pyc
U ����i�f������������������������@���s���d�Z�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlm Z �ddlmZmZmZmZmZ�dZe��ZdZG�dd ��d e�ZG�d d��de�ZG�dd ��d e�ZG�dd��de�Zdd��Zg�Zdd��Zdd��Z dd��Z!dd��Z"dd��Z#dd��Z$dd��Z%G�d d!��d!�Z&G�d"d#��d#e&�Z'G�d$d%��d%e'�Z(G�d&d'��d'e'�Z)e�*d(d)d*g�Z+G�d+d,��d,ej,�Z-G�d-d.��d.e&�Z.G�d/d0��d0ej/�Z0G�d1d2��d2e�Z1G�d3d4��d4e1�Z2G�d5d6��d6e1�Z3dS�)7zTest case implementation�����N����)�result)�strclass� safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@ Diff is %s characters long. Set self.maxDiff to None to see it.c�������������������@���s���e�Zd�ZdZdS�)�SkipTestz� Raise this exception in a test to skip it. Usually you can use TestCase.skipTest() or one of the skipping decorators instead of raising this directly. N��__name__� __module__�__qualname__�__doc__��r���r����2/opt/alt/python38/lib64/python3.8/unittest/case.pyr ������s���r ���c�������������������@���s���e�Zd�ZdZdS�)�_ShouldStopz The test should stop. Nr ���r���r���r���r���r���"���s���r���c�������������������@���s���e�Zd�ZdZdS�)�_UnexpectedSuccessz7 The test was supposed to fail, but it didn't! Nr ���r���r���r���r���r���'���s���r���c�������������������@���s&���e�Zd�Zddd�Zejddd��ZdS�) �_OutcomeNc�����������������C���s4���d|�_�||�_t|d�|�_d|�_g�|�_d�|�_g�|�_d�S�)NF� addSubTestT)�expecting_failurer����hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfr���r���r���r����__init__.���s����z_Outcome.__init__Fc�������������� ���c���s����|�j�}d|�_�z�z d�V��W�n��tk r.�����Y�n��tk rh�}�zd|�_�|�j�|t|�f��W�5�d�}~X�Y�nj�tk rz���Y�nX���t���}|�j r�||�_ nd|�_�|�j�||f��d�}Y�nX�|�jr�|�j�r�|�j�|d�f��W�5�|�j�o�||�_�X�d�S�)NTF) r����KeyboardInterruptr ���r����append�strr����sys�exc_infor���r���r���r���)r���� test_case�isTestZold_success�er"���r���r���r����testPartExecutor7���s*���� $ z_Outcome.testPartExecutor)N)F)r���r���r ���r���� contextlib�contextmanagerr&���r���r���r���r���r���-���s��� r���c�����������������C���s���|�S��Nr���)�objr���r���r����_idU���s����r+���c����������������O���s���t��|�||f��dS�)znSame as addCleanup, except the cleanup items are called even if setUpModule fails (unlike tearDownModule).N)�_module_cleanupsr���)�function�args�kwargsr���r���r����addModuleCleanupZ���s����r0���c��������������� ���C���sd���g�}�t�rTt����\}}}z|||��W�q�tk rP�}�z|��|��W�5�d}~X�Y�qX�q|�r`|�d��dS�)zWExecute all module cleanup functions. Normally called for you after tearDownModule.Nr���)r,����pop� Exceptionr���)� exceptionsr-���r.���r/����excr���r���r����doModuleCleanups`���s����r5���c��������������������s,�����fdd�}t���tj�r(��}d��||�S�|S�)z& Unconditionally skip a test. c��������������������s4���t�|�t�s$t�|����fdd��}|}�d|�_��|�_|�S�)Nc���������������������s���t�����d�S�r)����r ����r.���r/�����reasonr���r����skip_wrapperv���s����z-skip.<locals>.decorator.<locals>.skip_wrapperT)� isinstance�type� functools�wraps�__unittest_skip__�__unittest_skip_why__)� test_itemr:���r8���r���r���� decoratort���s���� zskip.<locals>.decorator��)r;����types�FunctionType)r9���rB���rA���r���r8���r����skipp���s���� rF���c�����������������C���s���|�rt�|�S�tS�)z/ Skip a test if the condition is true. �rF���r+����Z conditionr9���r���r���r����skipIf����s����rI���c�����������������C���s���|�st�|�S�tS�)z3 Skip a test unless the condition is true. rG���rH���r���r���r���� skipUnless����s����rJ���c�����������������C���s ���d|�_�|�S�)NT)�__unittest_expecting_failure__)rA���r���r���r���r�������s����r���c��������������������s4���t�|�t�r t��fdd�|�D���S�t�|�t�o2t|����S�)Nc�����������������3���s���|�]}t�|���V��qd�S�r)���)�_is_subtype)�.0r%�����basetyper���r���� <genexpr>����s�����z_is_subtype.<locals>.<genexpr>)r;����tuple�allr<���� issubclass)�expectedrO���r���rN���r���rL�������s���� rL���c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)�_BaseTestCaseContextc�����������������C���s ���||�_�d�S�r)���)r#���)r���r#���r���r���r���r�������s����z_BaseTestCaseContext.__init__c�����������������C���s ���|�j��|�j|�}|�j��|��d�S�r)���)r#����_formatMessage�msg�failureException)r����standardMsgrW���r���r���r���� _raiseFailure����s����z"_BaseTestCaseContext._raiseFailureN)r���r���r ���r���rZ���r���r���r���r���rU�������s���rU���c�������������������@���s���e�Zd�Zddd�Zdd��ZdS�)�_AssertRaisesBaseContextNc�����������������C���s@���t��|�|��||�_||�_|d�k r*t�|�}||�_d�|�_d�|�_d�S�r)���) rU���r���rT���r#����re�compile�expected_regex�obj_namerW���)r���rT���r#���r^���r���r���r���r�������s���� z!_AssertRaisesBaseContext.__init__c�������������� ���C���s����z�t�|�j|�j�s"td||�jf���|sV|�dd�|�_|rNtdtt|��f���|�W��TS�|^}}z|j |�_ W�n�tk r����t|�|�_ Y�nX�|���|||��W�5�Q�R�X�W�5�d}�X�dS�)z� If args is empty, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. If args is not empty, call a callable passing positional and keyword arguments. Nz%s() arg 1 must be %srW���z3%r is an invalid keyword argument for this function) rL���rT���� _base_type� TypeError�_base_type_strr1���rW����next�iterr���r_����AttributeErrorr ���)r����namer.���r/���Zcallable_objr���r���r����handle����s(������z_AssertRaisesBaseContext.handle)N)r���r���r ���r���rg���r���r���r���r���r[�������s��� r[���c�������������������@���s(���e�Zd�ZdZeZdZdd��Zdd��ZdS�)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typesc�����������������C���s���|�S�r)���r����r���r���r���r���� __enter__����s����z_AssertRaisesContext.__enter__c�����������������C���s����|d�krbz|�j�j}W�n�tk r2���t|�j��}Y�nX�|�jrP|��d�||�j���ql|��d�|���n t�|��t ||�j��s|dS�|� d��|�_|�jd�kr�dS�|�j}|� t|��s�|��d�|jt|����dS�)Nz{} not raised by {}z {} not raisedFT�"{}" does not match "{}")rT���r���re���r ���r_���rZ����format� traceback�clear_framesrS����with_tracebackZ exceptionr^����search�pattern)r����exc_type� exc_value�tb�exc_namer^���r���r���r����__exit__����s.���� � ��z_AssertRaisesContext.__exit__N) r���r���r ���r���� BaseExceptionr`���rb���rj���rv���r���r���r���r���rh�������s ���rh���c�������������������@���s(���e�Zd�ZdZeZdZdd��Zdd��ZdS�)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typesc�����������������C���sR���t�tj����D�]}t|dd��ri�|_qtjdd�|�_|�j� ��|�_t� d|�j��|�S�)N�__warningregistry__T)�record�always)�listr!����modules�values�getattrry����warnings�catch_warnings�warnings_managerrj����simplefilterrT���)r����vr���r���r���rj�������s����z_AssertWarnsContext.__enter__c�����������������C���s���|�j��|||��|d�k rd�S�z|�jj}W�n�tk rF���t|�j�}Y�nX�d�}|�jD�]Z}|j}t||�j�sjqR|d�krv|}|�j d�k r�|�j � t|��s�qR||�_|j|�_|j |�_ �d�S�|d�k r�|��d�|�j jt|����|�jr�|��d�||�j���n|��d�|���d�S�)Nrk���z{} not triggered by {}z{} not triggered)r����rv���rT���r���re���r ���r�����messager;���r^���rp���Zwarning�filename�linenorZ���rl���rq���r_���)r���rr���rs���rt���ru���Zfirst_matching�m�wr���r���r���rv�����s@���� ��� �z_AssertWarnsContext.__exit__N) r���r���r ���r����Warningr`���rb���rj���rv���r���r���r���r���rx�������s ���rx����_LoggingWatcher�records�outputc�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �_CapturingHandlerzM A logging handler capturing all (raw and formatted) logging output. c�����������������C���s���t�j�|���tg�g��|�_d�S�r)���)�logging�Handlerr���r�����watcherri���r���r���r���r���3��s����z_CapturingHandler.__init__c�����������������C���s���d�S�r)���r���ri���r���r���r����flush7��s����z_CapturingHandler.flushc�����������������C���s*���|�j�j�|��|��|�}|�j�j�|��d�S�r)���)r����r����r���rl���r����)r���rz���rW���r���r���r����emit:��s���� z_CapturingHandler.emitN)r���r���r ���r���r���r����r����r���r���r���r���r����.��s���r����c�������������������@���s,���e�Zd�ZdZdZdd��Zdd��Zdd��Zd S�) �_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)sc�����������������C���s:���t��|�|��||�_|r(tj�||�|�_ntj|�_d�|�_d�S�r)���) rU���r����logger_namer����Z_nameToLevel�get�level�INFOrW���)r���r#���r����r����r���r���r���r���F��s����z_AssertLogsContext.__init__c�����������������C���s����t�|�jtj�r|�j�}|�_nt�|�j��}|�_t�|�j�}t��}|� |��|j |�_ |jd�d���|�_|j |�_|j|�_|g|_|�|�j ��d|_|j S�)NF)r;���r����r����ZLogger�loggerZ getLoggerZ Formatter�LOGGING_FORMATr����ZsetFormatterr�����handlers�old_handlersr����� old_level� propagate� old_propagate�setLevel)r���r����Z formatterZhandlerr���r���r���rj���O��s���� z_AssertLogsContext.__enter__c�����������������C���s`���|�j�|�j_|�j|�j_|�j�|�j��|d�k r.dS�t|�jj �dkr\|�� d�t� |�j�|�jj���d�S�)NFr���z-no logs of level {} or higher triggered on {})r����r����r����r����r����r����r�����lenr����r����rZ���rl���r����ZgetLevelNamer����rf���)r���rr���rs���rt���r���r���r���rv���`��s���� ���z_AssertLogsContext.__exit__N)r���r���r ���r���r����r���rj���rv���r���r���r���r���r����A��s ��� r����c�������������������@���s���e�Zd�Zdd��ZdS�)�_OrderedChainMapc�����������������c���s8���t���}|�jD�]&}|D�]}||kr|�|��|V��qqd�S�r)���)�set�maps�add)r����seen�mapping�kr���r���r����__iter__n��s���� z_OrderedChainMap.__iter__N)r���r���r ���r����r���r���r���r���r����m��s���r����c�������������������@���s��e�Zd�ZdZeZdZdZdZdZ g�Z d�dd�Zd d ��Zdd��Z d e _edd���Zdd��Zdd��Zedd���Zedd���Zdd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zd&d'��Zd(d)��Zeje fd*d+��Z!d,d-��Z"d.d/��Z#d0d1��Z$d2d3��Z%d4d5��Z&d6d7��Z'd8d9��Z(d�d;d<�Z)d=d>��Z*ed?d@���Z+dAdB��Z,dCdD��Z-dEdF��Z.d�dGdH�Z/d�dIdJ�Z0d�dKdL�Z1dMdN��Z2dOdP��Z3dQdR��Z4d�dSdT�Z5dUdV��Z6d�dWdX�Z7d�dYdZ�Z8d�d[d\�Z9d�d]d^�Z:d�d_d`�Z;d�dadb�Z<dcdd��Z=d�dedf�Z>d�dgdh�Z?d�didj�Z@d�dkdl�ZAd�dmdn�ZBd�dodp�ZCd�dqdr�ZDd�dsdt�ZEd�dudv�ZFd�dwdx�ZGd�dydz�ZHd�d{d|�ZId�d}d~�ZJd�dd��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZPd�d���ZQd�d���ZRd�d�d��ZSd�d�d��ZTd�d���ZUeUe8��ZVZWeUe9��ZXZYeUe:��ZZZ[eUe;��Z\Z]eUe1��Z^Z_eUe3�Z`eUe0�ZaeUeQ�ZbeUeS�ZceUeT�Zdd:S�)��TestCaseaW��A class whose instances are single test cases. By default, the test code itself should be placed in a method named 'runTest'. If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute. Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test's environment ('fixture') can be implemented by overriding the 'setUp' and 'tearDown' methods respectively. If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run. When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when the instance's assertion methods fail; test methods raising this exception will be deemed to have 'failed' rather than 'errored'. * longMessage: determines whether long messages (including repr of objects used in assert methods) will be printed on failure in *addition* to any explicit message passed. * maxDiff: sets the maximum length of a diff in failure messages by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required. Ti���i���F�runTestc�����������������C���s����||�_�d|�_d|�_zt|�|�}W�n.�tk rN���|dkrJtd|�j|f���Y�n X�|j|�_g�|�_d|�_ i�|�_ |��td��|��t d��|��td��|��td��|��td��|��td ��dS�) z�Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. NzNo testr����zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocr���re���� ValueError� __class__r���� _cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|���rQ���r����� frozensetr ���)r���Z methodName� testMethodr���r���r���r������s(�����zTestCase.__init__c�����������������C���s���||�j�|<�dS�)a[��Add a type specific assertEqual style function to compare a type. This method is for use by TestCase subclasses that need to register their own type equality functions to provide nicer error messages. Args: typeobj: The data type to call this function on when both values are of the same type in assertEqual(). function: The callable taking two arguments and an optional msg= argument that raises self.failureException with a useful error message when the two arguments are not equal. N)r����)r���Ztypeobjr-���r���r���r���r�������s���� zTestCase.addTypeEqualityFuncc������������������O���s����t�|��dkr|�^}}}�nV|�s&td��nHd|krZ|�d�}|�^}}�ddl}|jdtdd��ntdt�|��d ����t|��}�|j�||�|f��dS�) a��Add a function, with arguments, to be called when the test is completed. Functions added are called on a LIFO basis and are called after tearDown on test failure or success. Cleanup items are called even if setUp fails (unlike tearDown).����z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-���r���Nz4Passing 'function' as keyword argument is deprecated)� stacklevelz:addCleanup expected at least 1 positional argument, got %dr���) r����ra���r1���r�����warn�DeprecationWarningrQ���r����r���)r.���r/���r���r-���r����r���r���r���� addCleanup���s"���� �� �zTestCase.addCleanupz%($self, function, /, *args, **kwargs)c����������������O���s���|�j��|||f��dS�)zpSame as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).N)�_class_cleanupsr���)�clsr-���r.���r/���r���r���r����addClassCleanup���s����zTestCase.addClassCleanupc�����������������C���s���dS�)zAHook method for setting up the test fixture before exercising it.Nr���ri���r���r���r����setUp���s����zTestCase.setUpc�����������������C���s���dS�)zAHook method for deconstructing the test fixture after testing it.Nr���ri���r���r���r����tearDown���s����zTestCase.tearDownc�����������������C���s���dS�)zKHook method for setting up class fixture before running tests in the class.Nr����r����r���r���r���� setUpClass���s����zTestCase.setUpClassc�����������������C���s���dS�)zVHook method for deconstructing the class fixture after running all tests in the class.Nr���r����r���r���r���� tearDownClass��s����zTestCase.tearDownClassc�����������������C���s���dS�)Nr���r���ri���r���r���r����countTestCases��s����zTestCase.countTestCasesc�����������������C���s���t����S�r)���)r���Z TestResultri���r���r���r����defaultTestResult ��s����zTestCase.defaultTestResultc�����������������C���s$���|�j�}|r |����d�d����S�dS�)z�Returns a one-line description of the test, or None if no description has been provided. The default implementation of this method returns the first line of the specified test method's docstring. � r���N)r�����strip�split�r����docr���r���r����shortDescription��s����zTestCase.shortDescriptionc�����������������C���s���dt�|�j�|�jf�S�)Nz%s.%s�r���r����r����ri���r���r���r����id��s����zTestCase.idc�����������������C���s ���t�|��t�|�k rtS�|�j|jkS�r)���)r<����NotImplementedr�����r����otherr���r���r����__eq__��s����zTestCase.__eq__c�����������������C���s���t�t|��|�jf�S�r)���)�hashr<���r����ri���r���r���r����__hash__ ��s����zTestCase.__hash__c�����������������C���s���d|�j�t|�j�f�S��Nz%s (%s))r����r���r����ri���r���r���r����__str__#��s����zTestCase.__str__c�����������������C���s���dt�|�j�|�jf�S�)Nz<%s testMethod=%s>r����ri���r���r���r����__repr__&��s�����zTestCase.__repr__c�����������������C���s<���t�|dd��}|d�k r |||��nt�dtd��|�|��d�S�)N�addSkipz4TestResult has no addSkip method, skips not reportedr����)r���r����r�����RuntimeWarning� addSuccess)r���r���r#���r9���r����r���r���r����_addSkip*��s������zTestCase._addSkipc�������������� ���k���s����|�j�dks|�j�jsdV��dS�|�j}|dkr4t|�}n|j�|�}t|�||�|�_zX|�j�j|�jdd���dV��W�5�Q�R�X�|�j�js�|�j�j }|dk r�|j r�t�n|�j�jr�t�W�5�||�_X�dS�)aP��Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed. NT�r$���) r����r���r����r�����params� new_child�_SubTestr&���r���r���Zfailfastr���r���)r���rW���r�����parentZ params_mapr���r���r���r����subTest3��s$���� zTestCase.subTestc�����������������C���s`���|D�]V\}}t�|t�r(|�|j||��q|d�k rt|d�|�j�rN|�||��q|�||��qd�S�)Nr���)r;���r����r���r#���rS���rX���� addFailureZaddError)r���r���r����testr"���r���r���r����_feedErrorsToResultR��s���� zTestCase._feedErrorsToResultc�����������������C���sD���z |j�}W�n*�tk r4���t�dt��|�|���Y�nX�||�|��d�S�)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurere���r����r����r����r����)r���r���r"���r����r���r���r����_addExpectedFailure\��s���� �zTestCase._addExpectedFailurec�����������������C���sh���z |j�}W�nP�tk rZ���t�dt��z td��W�n$�tk rT���|�|�t�����Y�nX�Y�n X�||���d�S�)NzCTestResult has no addUnexpectedSuccess method, reporting as failure) �addUnexpectedSuccessre���r����r����r����r���r����r!���r"���)r���r���r����r���r���r����_addUnexpectedSuccessf��s���� � zTestCase._addUnexpectedSuccessc�����������������C���s���|������d�S�r)���)r����ri���r���r���r���� _callSetUpu��s����zTestCase._callSetUpc�����������������C���s ���|���d�S�r)���r���)r����methodr���r���r����_callTestMethodx��s����zTestCase._callTestMethodc�����������������C���s���|������d�S�r)���)r����ri���r���r���r���� _callTearDown{��s����zTestCase._callTearDownc����������������O���s���|||��d�S�r)���r����r���r-���r.���r/���r���r���r����_callCleanup~��s����zTestCase._callCleanupNc����������� ��� ���C���s��|}|d�kr.|�����}t|dd��}|d�k r.|���|�|���t|�|�j�}t|�jdd�s^t|dd�r�z,t|�jdd�pxt|dd�}|��||�|��W�5�|�|���X�d�S�t|dd�}t|�dd�}|p�|}t|�} z�| |�_| �|����|�� ���W�5�Q�R�X�| j�r@|| _| j|�dd ���|��|��W�5�Q�R�X�d| _| �|����|�����W�5�Q�R�X�|�����| jD�]\}}|��|||���qN|��|| j��| j�r�|�r�| j �r�|��|| j ��n |��|��n |�|���|W��S�|�|���|d�k�r�t|dd��} | d�k �r�| ���| j� ���d�| _ d�|�_X�d�S�) N�startTestRunr?���Fr@���rC���rK����stopTestRunTr����)r����r���Z startTestr����r����ZstopTestr����r���r����clearr���r����r&���r����r���r���r����r����� doCleanupsr���r����r����r����r����) r���r���Zorig_resultr����r����Zskip_whyZexpecting_failure_methodZexpecting_failure_classr����outcomer����r����r9���r���r���r����run���st���� � ����� zTestCase.runc�������������� ���C���sR���|�j�p t��}|�jrL|�j���\}}}|�|����|�j|f|�|��W�5�Q�R�X�q|jS�)zNExecute all cleanup functions. Normally called for you after tearDown.)r����r���r����r1���r&���r����r���)r���r����r-���r.���r/���r���r���r���r�������s����zTestCase.doCleanupsc�������������� ���C���sd���g�|�_�|�jr`|�j���\}}}z|||��W�q�tk r\�}�z|�j��t�����W�5�d}~X�Y�qX�qdS�)zYExecute all class cleanup functions. Normally called for you after tearDownClass.N)ZtearDown_exceptionsr����r1���r2���r���r!���r"���)r����r-���r.���r/���r4���r���r���r����doClassCleanups���s����zTestCase.doClassCleanupsc�����������������O���s���|�j�||�S�r)���)r����)r���r.����kwdsr���r���r����__call__���s����zTestCase.__call__c�����������������C���sF���|������t|�|�j����|�����|�jrB|�j�d�\}}}|||��qdS�)z6Run the test without collecting errors in a TestResult���N)r����r���r����r����r����r1���r����r���r���r����debug���s����zTestCase.debugc�����������������C���s���t�|��dS�)zSkip this test.Nr6���)r���r9���r���r���r����skipTest���s����zTestCase.skipTestc�����������������C���s���|���|��dS�)z)Fail immediately, with the given message.N)rX���)r���rW���r���r���r����fail���s����z TestCase.failc�����������������C���s&���|r"|���|dt|���}|��|��dS�)z#Check that the expression is false.z%s is not falseN�rV���r���rX����r����exprrW���r���r���r����assertFalse���s����zTestCase.assertFalsec�����������������C���s&���|s"|���|dt|���}|��|��dS�)z"Check that the expression is true.z%s is not trueNr��r��r���r���r���� assertTrue���s����zTestCase.assertTruec�����������������C���sV���|�j�s|p|S�|dkr|S�zd||f�W�S��tk rP���dt|�t|�f��Y�S�X�dS�)a���Honour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert If longMessage is True: * Use the standard message * If an explicit message is provided, plus ' : ' and the explicit message Nz%s : %s)�longMessage�UnicodeDecodeErrorr���)r���rW���rY���r���r���r���rV������s���� zTestCase._formatMessagec�����������������O���s(���t�||��}z|�d||�W��S�d}X�dS�)a=��Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. If called with the callable and arguments omitted, will return a context object used like this:: with self.assertRaises(SomeException): do_something() An optional keyword argument 'msg' can be provided when assertRaises is used as a context object. The context manager keeps a reference to the exception as the 'exception' attribute. This allows you to inspect the exception after the assertion:: with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) N�assertRaises�rh���rg���)r����expected_exceptionr.���r/����contextr���r���r���r����s���� zTestCase.assertRaisesc�����������������O���s���t�||��}|�d||�S�)a���Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception. If called with the callable and arguments omitted, will return a context object used like this:: with self.assertWarns(SomeWarning): do_something() An optional keyword argument 'msg' can be provided when assertWarns is used as a context object. The context manager keeps a reference to the first matching warning as the 'warning' attribute; similarly, the 'filename' and 'lineno' attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:: with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) �assertWarns�rx���rg���)r����expected_warningr.���r/���r��r���r���r���r��5��s���� zTestCase.assertWarnsc�����������������C���s���t�|�||�S�)a���Fail unless a log message of level *level* or higher is emitted on *logger_name* or its children. If omitted, *level* defaults to INFO and *logger* defaults to the root logger. This method must be used as a context manager, and will yield a recording object with two attributes: `output` and `records`. At the end of the context manager, the `output` attribute will be a list of the matching formatted log messages and the `records` attribute will be a list of the corresponding LogRecord objects. Example:: with self.assertLogs('foo', level='INFO') as cm: logging.getLogger('foo').info('first message') logging.getLogger('foo.bar').error('second message') self.assertEqual(cm.output, ['INFO:foo:first message', 'ERROR:foo.bar:second message']) )r����)r���r����r����r���r���r���� assertLogsT��s����zTestCase.assertLogsc�����������������C���sF���t�|�t�|�kr@|�j�t�|��}|dk r@t|t�r<t|�|�}|S�|�jS�)a��Get a detailed comparison function for the types of the two args. Returns: A callable accepting (first, second, msg=None) that will raise a failure exception if first != second with a useful human readable error message for those types. N)r<���r����r����r;���r ���r����_baseAssertEqual)r����first�secondZasserterr���r���r����_getAssertEqualityFuncj��s���� zTestCase._getAssertEqualityFuncc�����������������C���s0���||ks,dt�||��}|��||�}|��|��dS�)z:The default assertEqual implementation, not type specific.�%s != %sN)r���rV���rX���)r���r��r��rW���rY���r���r���r���r�����s����zTestCase._baseAssertEqualc�����������������C���s���|���||�}||||d��dS�)z[Fail if the two objects are unequal as determined by the '==' operator. )rW���N)r��)r���r��r��rW���Zassertion_funcr���r���r����assertEqual���s����zTestCase.assertEqualc�����������������C���s2���||ks.|���|dt|�t|�f��}|��|��dS�)zYFail if the two objects are equal as determined by the '!=' operator. z%s == %sNr��)r���r��r��rW���r���r���r����assertNotEqual���s �����zTestCase.assertNotEqualc�����������������C���s����||krdS�|dk r$|dk r$t�d��t||��}|dk rf||krDdS�dt|�t|�t|�t|�f�}n:|dkrrd}t||�dkr�dS�dt|�t|�|t|�f�}|��||�}|��|��dS�)a'��Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit). If the two objects compare equal then they will automatically compare almost equal. N� specify delta or places not bothz(%s != %s within %s delta (%s difference)����r���z)%s != %s within %r places (%s difference)�ra����absr����roundrV���rX����r���r��r��ZplacesrW���Zdelta�diffrY���r���r���r����assertAlmostEqual���s4������zTestCase.assertAlmostEqualc�����������������C���s����|dk r|dk rt�d��t||��}|dk rb||ks@||kr@dS�dt|�t|�t|�t|�f�}n<|dkrnd}||ks�t||�dkr�dS�dt|�t|�|f�}|��||�}|��|��dS�)a���Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit). Objects that are equal automatically fail. Nr��z(%s == %s within %s delta (%s difference)r��r���z%s == %s within %r placesr��r��r���r���r����assertNotAlmostEqual���s,������zTestCase.assertNotAlmostEqualc�����������������C���s���|dk rP|j�}t||�s.|��d|t|�f���t||�sT|��d|t|�f���nd}d}zt|�}W�n �ttfk r����d|�}Y�nX�|dkr�zt|�}W�n �ttfk r����d|�}Y�nX�|dk�r�||kr�dS�d|���ft||���}t t ||��D�]�} z|| �} W�n4�tttfk �r<���|d| |f�7�}Y���q�Y�nX�z|| �}W�n4�tttfk �r~���|d | |f�7�}Y���q�Y�nX�| |kr�|d | ft| |���7�}��q�q�||k�r�|dk�r�t|�t|�k�r�dS�||k�r<|d|||�f�7�}z|d|t||��f�7�}W�n,�tttfk �r8���|d ||f�7�}Y�nX�nh||k��r�|d|||�f�7�}z|d|t||��f�7�}W�n,�tttfk �r����|d||f�7�}Y�nX�|}dd� t�t�|����t�|�������} |��|| �}|��||�}|��|��dS�)aA��An equality assertion for ordered sequences (like lists and tuples). For the purposes of this function, a valid ordered sequence type is one which can be indexed, has a length, and has an equality operator. Args: seq1: The first sequence to compare. seq2: The second sequence to compare. seq_type: The expected datatype of the sequences, or None if no datatype should be enforced. msg: Optional message to use on failure instead of a list of differences. NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length. Non-sequence?z)Second %s has no length. Non-sequence?z%ss differ: %s != %s z( Unable to index element %d of first %s z) Unable to index element %d of second %s z# First differing element %d: %s %s z+ First %s contains %d additional elements. zFirst extra element %d: %s z'Unable to index element %d of first %s z, Second %s contains %d additional elements. z(Unable to index element %d of second %s r����)r���r;���rX���r���r����ra����NotImplementedError� capitalizer����range�min� IndexErrorr<����join�difflib�ndiff�pprint�pformat� splitlines�_truncateMessagerV���r���)r���Zseq1Zseq2rW����seq_typeZ seq_type_nameZ differingZlen1Zlen2�iZitem1Zitem2rY����diffMsgr���r���r����assertSequenceEqual���s����� � �� � ������ �� � �� ���zTestCase.assertSequenceEqualc�����������������C���s2���|�j�}|d�kst|�|kr"||�S�|tt|���S�r)���)�maxDiffr�����DIFF_OMITTED)r���r����r��Zmax_diffr���r���r���r+��N��s����zTestCase._truncateMessagec�����������������C���s���|�j�|||td��dS�)a��A list-specific equality assertion. Args: list1: The first list to compare. list2: The second list to compare. msg: Optional message to use on failure instead of a list of differences. �r,��N)r/��r|���)r���Zlist1Zlist2rW���r���r���r���r����T��s���� zTestCase.assertListEqualc�����������������C���s���|�j�|||td��dS�)a��A tuple-specific equality assertion. Args: tuple1: The first tuple to compare. tuple2: The second tuple to compare. msg: Optional message to use on failure instead of a list of differences. r2��N)r/��rQ���)r���Ztuple1Ztuple2rW���r���r���r���r����`��s���� zTestCase.assertTupleEqualc����������� ��� ���C���s`��z|��|�}W�n^�tk r>�}�z|��d|���W�5�d}~X�Y�n0�tk rl�}�z|��d|���W�5�d}~X�Y�nX�z|��|�}W�n^�tk r��}�z|��d|���W�5�d}~X�Y�n0�tk r��}�z|��d|���W�5�d}~X�Y�nX�|s�|s�dS�g�}|�r|�d��|D�]}|�t|����q�|�r@|�d��|D�]}|�t|����q*d�|�} |��|��|| ���dS�)a���A set-specific equality assertion. Args: set1: The first set to compare. set2: The second set to compare. msg: Optional message to use on failure instead of a list of differences. assertSetEqual uses ducktyping to support different types of sets, and is optimized for sets specifically (parameters must support a difference method). z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r����)� differencera���r���re���r����reprr%��rV���) r���Zset1Zset2rW���Zdifference1r%���Zdifference2�lines�itemrY���r���r���r���r����k��s2���� zTestCase.assertSetEqualc�����������������C���s2���||kr.dt�|�t�|�f�}|��|��||���dS�)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN�r���r���rV����r����memberZ containerrW���rY���r���r���r����assertIn���s �����zTestCase.assertInc�����������������C���s2���||kr.dt�|�t�|�f�}|��|��||���dS�)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7��r8��r���r���r����assertNotIn���s �����zTestCase.assertNotInc�����������������C���s2���||k r.dt�|�t�|�f�}|��|��||���dS�)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sNr7���r���Zexpr1Zexpr2rW���rY���r���r���r����assertIs���s �����zTestCase.assertIsc�����������������C���s,���||kr(dt�|�f�}|��|��||���dS�)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7��r<��r���r���r����assertIsNot���s����zTestCase.assertIsNotc�������������� ���C���s~���|���|td��|���|td��||krzdt||��}dd�t�t�|����t�|�������}|�� ||�}|�� |��||���d�S�)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryr��r����)�assertIsInstancer����r���r%��r&��r'��r(��r)��r*��r+��r���rV���)r���Zd1Zd2rW���rY���r��r���r���r���r�������s���� �zTestCase.assertDictEqualc����������� ��� ���C���s����t��dt��g�}g�}|���D�]L\}}||kr8|�|��q|||�kr|�dt|�t|�t||��f���q|sv|svdS�d}|r�dd�dd��|D����}|r�|r�|d 7�}|d d�|��7�}|��|��||���dS�)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrC���zMissing: %s�,c�����������������s���s���|�]}t�|�V��qd�S�r)���)r���)rM���r����r���r���r���rP������s�����z4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s) r����r����r�����itemsr���r���r%��r���rV���) r���ZsubsetZ dictionaryrW���ZmissingZ mismatched�key�valuerY���r���r���r����assertDictContainsSubset���s4����� ��� z!TestCase.assertDictContainsSubsetc����������� ������C���s����t�|�t�|��}}zt�|�}t�|�}W�n�tk rH���t||�}Y�nX�||krVdS�t||�}|r�d}dd��|D��}d�|�} |��|| �}|��||�}|�� |��dS�)a[��Asserts that two iterables have the same elements, the same number of times, without regard to order. self.assertEqual(Counter(list(first)), Counter(list(second))) Example: - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal. NzElement counts were not equal: c�����������������S���s���g�|�]}d�|��qS�)z First has %d, Second has %d: %rr���)rM���r��r���r���r���� <listcomp>���s�����z-TestCase.assertCountEqual.<locals>.<listcomp>r����) r|����collections�Counterra���r���r���r%��r+��rV���r���) r���r��r��rW���Z first_seqZ second_seqZdifferencesrY���r5��r.��r���r���r����assertCountEqual���s ���� zTestCase.assertCountEqualc�����������������C���s����|���|td��|���|td��||kr�t|�|�jks@t|�|�jkrN|��|||��|jdd�}|jdd�}t|�dkr�|�d�|kr�|d�g}|d�g}dt||��}dd �t � ||���}|��||�}|��|�� ||���d S�)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsr���z r����r��rC���N)r?��r ���r�����_diffThresholdr��r*��r����r���r%��r&��r'��r+��r���rV���)r���r��r��rW���Z firstlinesZsecondlinesrY���r��r���r���r���r�������s ����� zTestCase.assertMultiLineEqualc�����������������C���s2���||k�s.dt�|�t�|�f�}|��|��||���dS�)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr7���r����a�brW���rY���r���r���r���� assertLess��s����zTestCase.assertLessc�����������������C���s2���||ks.dt�|�t�|�f�}|��|��||���dS�)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr7��rK��r���r���r����assertLessEqual��s����zTestCase.assertLessEqualc�����������������C���s2���||ks.dt�|�t�|�f�}|��|��||���dS�)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7��rK��r���r���r���� assertGreater��s����zTestCase.assertGreaterc�����������������C���s2���||ks.dt�|�t�|�f�}|��|��||���dS�)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr7��rK��r���r���r����assertGreaterEqual ��s����zTestCase.assertGreaterEqualc�����������������C���s,���|dk r(dt�|�f�}|��|��||���dS�)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7���r���r*���rW���rY���r���r���r����assertIsNone&��s����zTestCase.assertIsNonec�����������������C���s"���|dkrd}|���|��||���dS�)z(Included for symmetry with assertIsNone.Nzunexpectedly None)r���rV���rR��r���r���r����assertIsNotNone,��s����zTestCase.assertIsNotNonec�����������������C���s0���t�||�s,dt|�|f�}|��|��||���dS�)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer default message.z%s is not an instance of %rN�r;���r���r���rV����r���r*���r����rW���rY���r���r���r���r?��2��s���� zTestCase.assertIsInstancec�����������������C���s0���t�||�r,dt|�|f�}|��|��||���dS�)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrU��rV��r���r���r����assertNotIsInstance9��s���� zTestCase.assertNotIsInstancec�����������������O���s���t�||�|�}|�d||�S�)a��Asserts that the message in a raised exception matches a regex. Args: expected_exception: Exception class expected to be raised. expected_regex: Regex (re.Pattern object or string) expected to be found in error message. args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used when assertRaisesRegex is used as a context manager. �assertRaisesRegexr ��)r���r ��r^���r.���r/���r��r���r���r���rX��?��s���� zTestCase.assertRaisesRegexc�����������������O���s���t�||�|�}|�d||�S�)a���Asserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches. Args: expected_warning: Warning class expected to be triggered. expected_regex: Regex (re.Pattern object or string) expected to be found in error message. args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. �assertWarnsRegexr ��)r���r��r^���r.���r/���r��r���r���r���rY��O��s����zTestCase.assertWarnsRegexc�����������������C���sV���t�|ttf�r$|std��t�|�}|�|�sRd|j|f�}|��||�}|�� |��dS�)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.z&Regex didn't match: %r not found in %rN) r;���r ����bytes�AssertionErrorr\���r]���rp���rq���rV���rX���)r����textr^���rW���rY���r���r���r����assertRegexb��s���� ��zTestCase.assertRegexc�����������������C���s`���t�|ttf�rt�|�}|�|�}|r\d||���|�����|j|f�}|�� ||�}|�� |��dS�)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r;���r ���rZ��r\���r]���rp����start�endrq���rV���rX���)r���r\��Zunexpected_regexrW����matchrY���r���r���r����assertNotRegexn��s���� �zTestCase.assertNotRegexc��������������������s�����fdd�}|S�)Nc���������������������s ���t��d���j�td����|�|�S�)NzPlease use {0} instead.r����)r����r����rl���r���r����r7����� original_funcr���r����deprecated_func~��s���� ��z,TestCase._deprecate.<locals>.deprecated_funcr���)rc��rd��r���rb��r���� _deprecate}��s����zTestCase._deprecate)r����)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)er���r���r ���r���r[��rX���r��r0��rJ��Z_classSetupFailedr����r���r����r�����__text_signature__�classmethodr����r����r����r����r����r����r����r����r����r����r����r����r����r����r'���r(����_subtest_msg_sentinelr����r����r����r����r����r����r����r����r����r����r����r����r����r����r���r��r��rV���r��r��r��r��r��r��r��r��r��r/��r+��r����r����r����r:��r;��r=��r>��r����rD��rH��r����rN��rO��rP��rQ��rS��rT��r?��rW��rX��rY��r]��ra��re��ZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesr���r���r���r���r����w��s���� E ! ��� -��� # c + r����c�����������������������sj���e�Zd�ZdZd��fdd� Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z ���ZS�)�FunctionTestCaseaI��A test case that wraps a test function. This is useful for slipping pre-existing test functions into the unittest framework. Optionally, set-up and tidy-up functions can be supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully. Nc��������������������s*���t�t|������||�_||�_||�_||�_d�S�r)���)�superri��r���� _setUpFunc� _tearDownFunc� _testFunc�_description)r���ZtestFuncr����r����Zdescription�r����r���r���r������s ����zFunctionTestCase.__init__c�����������������C���s���|�j�d�k r|������d�S�r)���)rk��ri���r���r���r���r�������s���� zFunctionTestCase.setUpc�����������������C���s���|�j�d�k r|������d�S�r)���)rl��ri���r���r���r���r�������s���� zFunctionTestCase.tearDownc�����������������C���s���|������d�S�r)���)rm��ri���r���r���r���r�������s����zFunctionTestCase.runTestc�����������������C���s���|�j�jS�r)���)rm��r���ri���r���r���r���r�������s����zFunctionTestCase.idc�����������������C���s@���t�||�j�stS�|�j|jko>|�j|jko>|�j|jko>|�j|jkS�r)���)r;���r����r����rk��rl��rm��rn��r����r���r���r���r�������s���� � � �zFunctionTestCase.__eq__c�����������������C���s���t�t|��|�j|�j|�j|�jf�S�r)���)r����r<���rk��rl��rm��rn��ri���r���r���r���r�������s������zFunctionTestCase.__hash__c�����������������C���s���dt�|�j�|�jjf�S�r����)r���r����rm��r���ri���r���r���r���r�������s���� �zFunctionTestCase.__str__c�����������������C���s���dt�|�j�|�jf�S�)Nz<%s tec=%s>)r���r����rm��ri���r���r���r���r�������s���� �zFunctionTestCase.__repr__c�����������������C���s2���|�j�d�k r|�j�S�|�jj}|r.|�d�d����p0d�S�)Nr����r���)rn��rm��r���r����r����r����r���r���r���r�������s���� z!FunctionTestCase.shortDescription)NNN)r���r���r ���r���r���r����r����r����r����r����r����r����r����r����� __classcell__r���r���ro��r���ri�����s��� ri��c�����������������������sD���e�Zd�Z��fdd�Zdd��Zdd��Zdd��Zd d ��Zdd��Z���Z S�) r����c��������������������s(���t�������||�_||�_||�_|j|�_d�S�r)���)rj��r����_messager#���r����rX���)r���r#���r����r����ro��r���r���r������s ���� z_SubTest.__init__c�����������������C���s���t�d��d�S�)Nzsubtests cannot be run directly)r ��ri���r���r���r���r�������s����z_SubTest.runTestc�����������������C���s^���g�}|�j�tk r |�d�|�j����|�jrPd�dd��|�j���D���}|�d�|���d�|�p\dS�)Nz[{}]z, c�����������������s���s���|�]\}}d���||�V��qdS�)z{}={!r}N)rl���)rM���r����r����r���r���r���rP������s����z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rq��rh��r���rl���r����r%��rA��)r����partsZparams_descr���r���r����_subDescription���s���� �z_SubTest._subDescriptionc�����������������C���s���d��|�j���|�����S��Nz{} {})rl���r#���r����rt��ri���r���r���r���r�������s����z_SubTest.idc�����������������C���s ���|�j����S�)zlReturns a one-line description of the subtest, or None if no description has been provided. )r#���r����ri���r���r���r���r�������s����z_SubTest.shortDescriptionc�����������������C���s���d��|�j|�����S�ru��)rl���r#���rt��ri���r���r���r���r�������s����z_SubTest.__str__) r���r���r ���r���r����rt��r����r����r����rp��r���r���ro��r���r�������s���r����)4r���r!���r=���r&��r����r(��r\���r����rF��r'���rm���rD���rC���r����utilr���r���r���r���r���Z __unittest�objectrh��r1��r2���r ���r���r���r���r+���r,���r0���r5���rF���rI���rJ���r���rL���rU���r[���rh���rx���� namedtupler����r����r����r�����ChainMapr����r����ri��r����r���r���r���r����<module>���sd���( *%5�, ��������$: