U
    Y»{j¬  ã                   @   sZ   d Z ddlZddlZddlZdZeg ƒZeg ƒZdeg ƒiZdd„ Z	G dd„ dej
ƒZ
dS )zL
This module provides the tools used to internally run the erfa test suite.
é    NFc               	   C   sT  t tj ¡ ƒD ]} t| tjƒrt| dƒr| `qt	s6dS t
 ¡  t
 dt¡ tD ]&}zt|ƒ W qN tk
rr   Y qNX qNt
 ¡  tttg}|D ]}t
 dd|¡ qŒtD ]}|D ]}t
jd||d� q¬q¤tD ]B}|dksætjdd… |krÈt| D ]}t
 d|d |d	 ¡ qîqÈzddl}W n tk
�r.   Y n"X |jd d
k �rPt
jdtdd� dS )zù
    Turn all DeprecationWarnings (which indicate deprecated uses of
    Python itself or Numpy) into exceptions so that we find
    out about them early.

    This completely resets the warning filters and any "already seen"
    warning state.
    Ú__warningregistry__NÚignoreÚerrorz.*)ÚcategoryÚmoduleé   r   é   Ú3znumpy.lib.type_check)ÚlistÚsysÚmodulesÚvaluesÚ
isinstanceÚtypesÚ
ModuleTypeÚhasattrr   Ú_deprecations_as_exceptionsÚwarningsÚresetwarningsÚsimplefilterÚDeprecationWarningÚ_modules_to_ignore_on_importÚ
__import__ÚImportErrorÚFutureWarningÚImportWarningÚfilterwarningsÚ!_warnings_to_ignore_entire_moduleÚ_warnings_to_ignore_by_pyverÚversion_infoÚ
matplotlibÚ__version__)r   ÚmZ
_all_warnsÚwÚvÚsr    © r&   úP/var/www/html/bwave/python/venv/lib/python3.8/site-packages/erfa/tests/helper.pyÚ treat_deprecations_as_exceptions   sB    ÿ
ÿr(   c                       s4   e Zd ZdZ‡ fdd„Z‡ fdd„Zdd„ Z‡  ZS )Úcatch_warningsa.  
    A high-powered version of warnings.catch_warnings to use for testing
    and to make sure that there is no dependence on the order in which
    the tests are run.

    This completely blitzes any memory of any warnings that have
    appeared before so that all warnings will be caught and displayed.

    ``*args`` is a set of warning classes to collect.  If no arguments are
    provided, all warnings are collected.

    Use as follows::

        with catch_warnings(MyCustomWarning) as w:
            do.something.bad()
        assert len(w) > 0
    c                    s   t ƒ jdd� || _d S )NT)Úrecord)ÚsuperÚ__init__Úclasses)Úselfr-   ©Ú	__class__r&   r'   r,   j   s    zcatch_warnings.__init__c                    sP   t ƒ  ¡ }tƒ  t| jƒdkr*t d¡ n"t d¡ | jD ]}t d|¡ q:|S )Nr   Úalwaysr   )r+   Ú	__enter__r(   Úlenr-   r   r   )r.   Zwarning_listÚclsr/   r&   r'   r2   n   s    


zcatch_warnings.__enter__c                 C   s
   t ƒ  d S )N)r(   )r.   ÚtypeÚvalueÚ	tracebackr&   r&   r'   Ú__exit__y   s    zcatch_warnings.__exit__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r,   r2   r8   Ú__classcell__r&   r&   r/   r'   r)   W   s   r)   )r<   r   r   r   r   Úsetr   r   r   r(   r)   r&   r&   r&   r'   Ú<module>   s    ÿD