U
    Gvf                     @   s   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 d dlmZ dd Zdd Zd	d
 Zejddddd ZdS )    N)get_fpu_mode)FPUModeChangeWarning)_pep440c                 C   sV   |  dd |  dd |  dd zdd l}W n  tk
rP   |  dd Y nX d S )Nmarkerszslow: Tests that are very slow.zHxslow: mark test as extremely slow (not run unless explicitly requested)z8xfail_on_32bit: mark test as failing on 32-bit platformsr   z.timeout: mark a test for a non-default timeout)Zaddinivalue_linepytest_timeout	Exception)configr    r	   2/tmp/pip-unpacked-wheel-96ln3f52/scipy/conftest.pypytest_configure   s      r   c                 C   s0   t tjt dkr"| |}n
| |}|S )Nz3.6.0)r   parsepytest__version__VersionZget_closest_markerZ
get_marker)itemnamemarkr	   r	   r
   	_get_mark   s    
r   c           	   	   C   sp  t | d}|d k	rPzttjdd}W n tk
r@   d}Y nX |sPtd t | d}|d k	rt	dj
dk rtd	|jd f  t }|tj zdd
lm} d}W n tk
r   d}Y nX |rbzttjd }W n" tk
r   Y W 5 Q R  d S X tdsbt d }t|| d}z||dd W n" tk
r`   Y W 5 Q R  d S X W 5 Q R X d S )NZxslowZSCIPY_XSLOW0Fz@very slow test; set environment variable SCIPY_XSLOW=1 to run itZxfail_on_32bitr      z(Fails on our 32-bit test platform(s): %s)threadpool_limitsTZPYTEST_XDIST_WORKER_COUNTZOMP_NUM_THREADS      Zblas)Zuser_api)r   intosenvironget
ValueErrorr   skipnpZintpitemsizeZxfailargsnptZsuppress_warningsfilterZ PytestUnraisableExceptionWarningZthreadpoolctlr   r   KeyErrorgetenv	cpu_countmax)	r   r   vsupr   ZHAS_THREADPOOLCTLZxdist_worker_countZmax_openmp_threadsZthreads_per_workerr	   r	   r
   pytest_runtest_setup#   s<    





r*   functionT)ZscopeZautousec                 c   s6   t  }dV  t  }||kr2tjd||tdd dS )z9
    Check FPU mode was not changed during the test.
    Nz6FPU mode changed from {0:#x} to {1:#x} during the testr   )category
stacklevel)r   warningswarnformatr   )requestZold_modeZnew_moder	   r	   r
   check_fpu_modeS   s      r2   )r   r   r.   Znumpyr   Znumpy.testingZtestingr"   Zscipy._lib._fpumoder   Zscipy._lib._testutilsr   Z
scipy._libr   r   r   r*   Zfixturer2   r	   r	   r	   r
   <module>   s   0