B
    îq\þ  ã               @   s¨   d Z ddlmZmZmZmZ ddlZ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 ddlmZ eddd	d
dgƒZddlmZ edefgƒZdd„ Zdd„ ZdS )z^
This plugin provides customization of the header displayed by pytest for
reporting purposes.
é    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literalsN)ÚOrderedDict)Úignore_warnings)Úresolve_name)ZNumpyZnumpy)ZScipyZscipy)Z
MatplotlibZ
matplotlib)Úh5pyr	   )ZPandasZpandas)Ú__version__ÚAstropyc          
      sä  yt jjpd}W n tk
r(   d}Y nX | j}ttƒdkrhx8t ¡ D ]\}}|dkrFd ||¡}qFW nd td ¡}t	| dƒr´t
| jƒ‰ ˆ  tj¡s ˆ tj7 ‰ ‡ fdd	„|D ƒ}n|}|d
 d |¡¡7 }|d tj ¡  ¡ d d… ¡7 }ddlm} |ƒ }t|tƒr| |d¡}|d |¡7 }|d t j¡7 }|d t j¡7 }|d t  ¡ t ¡ t  ¡ ¡7 }|d7 }|d t j¡7 }|d t j¡7 }x’t ¡ D ]†\}	}
y t t!ƒ t"|
ƒ}W d Q R X W n$ t#k
rà   |d |	¡7 }Y n8X y
|j$}W n tk
r   d}Y nX |d |	|¡7 }q”W dtkr2td }n,yddl%m&} W n t#k
r\   d }Y nX |rr|d |¡7 }ddg}g }xF|D ]>}t'| j(|d ƒ}|r„t|t
ƒr¶d  ||f¡}| )|¡ q„W |rà|d! d" |¡¡7 }|S )#NÚasciié   )r   Úastropy_helpersz%
Running tests with {0} version {1}.
z)
Running tests with Astropy version {0}.
r   Úrootdirc                s*   g | ]"}|  ˆ ¡r"|tˆ ƒd … n|‘qS )N)Ú
startswithÚlen)Ú.0Úarg)r   © ú<lib/python3.7/site-packages/astropy/tests/plugins/display.pyú
<listcomp>9   s   z(pytest_report_header.<locals>.<listcomp>zRunning tests in {0}.

ú zDate: {0}

é   r   )ÚplatformÚreplacezPlatform: {0}

zExecutable: {0}

zFull Python Version: 
{0}

z1encodings: sys: {0}, locale: {1}, filesystem: {2}Ú
zbyteorder: {0}
z-float info: dig: {0.dig}, mant_dig: {0.dig}

z{0}: not available
z"unknown (no __version__ attribute)z	{0}: {1}
r   )Úastropy_helpers_versionzastropy_helpers: {0}
Zremote_dataZpep8z: zUsing Astropy options: {0}.
z, )*ÚsysÚstdoutÚencodingÚAttributeErrorÚargsr   ÚTESTED_VERSIONSÚitemsÚformatÚhasattrÚstrr   ÚendswithÚosÚsepÚjoinÚdatetimeZnowZ	isoformatr   Ú
isinstanceÚbytesÚdecodeÚ
executableÚversionÚgetdefaultencodingÚlocaleZgetpreferredencodingÚgetfilesystemencodingÚ	byteorderÚ
float_infoÚPYTEST_HEADER_MODULESr   ÚDeprecationWarningr   ÚImportErrorr
   Zastropy.versionr   ÚgetattrZoptionÚappend)ZconfigZstdoutencodingr!   Úpkgr0   ÚsÚdirsr   ZplatZmodule_displayZmodule_nameÚmoduler   Zspecial_optsZoptsÚopZop_valuer   )r   r   Úpytest_report_header   s„    






 







r@   c             C   sL   y
t ƒ  W n tk
r   dS X | j d¡s0dS |  ¡  | jdddd dS )z;Output a warning to IPython users in case any tests failed.NZfailedaˆ  Some tests are known to fail when run from the IPython prompt; especially, but not limited to tests involving logging and warning handling.  Unless you are certain as to the cause of the failure, please check that the failure occurs outside IPython as well.  See http://docs.astropy.org/en/stable/known_issues.html#failing-logging-tests-when-running-the-tests-in-ipython for more information.T)ZyellowZbold)Zget_ipythonÚ	NameErrorZstatsÚgetZensure_newlineZ
write_line)Zterminalreporterr   r   r   Úpytest_terminal_summary{   s    
rC   )Ú__doc__Z
__future__r   r   r   r   r(   r   r+   r2   ZmathÚcollectionsr   Zastropy.tests.helperr   Zastropy.utils.introspectionr   r6   Zastropyr
   r"   r@   rC   r   r   r   r   Ú<module>   s$   \