U
    g                     @   s@  d 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ai Z	ej
eje d ejjdddd ejjdddddeejd	 ejejed
dZejejerdnd dd Zdd Zdd Ze dd Zejddddd Zejdddd Zejdddd Z ejddgddd  Z!dS )!z=
Pytest configuration and fixtures for the Numpy test suite.
    N)get_fpu_modez.hypothesisznumpy-profileT)namedeadline
print_blobznp.test() profile)r   r   r   ZdatabaseZderandomizeZsuppress_health_checkz..z
pytest.inic                 C   s4   |  dd |  dd |  dd |  dd d S )Nmarkersz=valgrind_error: Tests that are known to error under valgrind.z:leaks_references: Tests that are known to leak references.zslow: Tests that are very slow.z,slow_pypy: Tests that are very slow on pypy.)Zaddinivalue_line)config r   2/tmp/pip-unpacked-wheel-2wnnwvus/numpy/conftest.pypytest_configure,   s    r
   c                 C   s   | j ddd dd d S )Nz--available-memorystorezSet amount of memory available for running the test suite. This can result to tests requiring especially large amounts of memory to be skipped. Equivalent to setting environment variable NPY_AVAILABLE_MEM. Default: determinedautomatically.)actiondefaulthelp)Z	addoption)parserr   r   r	   pytest_addoption7   s    
r   c                 C   s"   | j d}|d k	r|tjd< d S )NZavailable_memoryZNPY_AVAILABLE_MEM)r   Z	getoptionosenviron)sessionZavailable_memr   r   r	   pytest_sessionstartA   s    r   c                 C   s0   t  }tdkr|an|tkr,t|ft| < |adS )z
    Check FPU precision mode was not changed during test collection.

    The clumsy way we do it here is mainly necessary because numpy
    still uses yield tests, which can execute code at test collection
    time.
    N)r   _old_fpu_mode_collect_results)itemmoder   r   r	   pytest_itemcollectedH   s    r   function)Zscopeautousec                 c   sZ   t  }dV  t  }||kr*td||t| j}|dk	rV|\}}td||dS )zC
    Check FPU precision mode was not changed during the test.
    Nz@FPU precision mode changed from {0:#x} to {1:#x} during the testzIFPU precision mode changed from {0:#x} to {1:#x} when collecting the test)r   AssertionErrorformatr   getnode)requestZold_modeZnew_modeZcollect_resultr   r   r	   check_fpu_mode\   s     r!   )r   c                 C   s   t | d< d S )Nnp)numpy)Zdoctest_namespacer   r   r	   add_npq   s    r$   c                 C   s   |  dd d S )NZPYTHONHASHSEED0)Zsetenv)Zmonkeypatchr   r   r	   	env_setupu   s    r&   F)paramsc                 c   s:   t  }| jrt d n
t d | jV  t | dS )z
    Fixture to ensure "legacy" promotion state or change it to use the new
    weak promotion (plus warning).  `old_promotion` should be used as a
    parameter in the function.
    Zweak_and_warnlegacyN)r#   Z_get_promotion_stateparamZ_set_promotion_state)r    stater   r   r	   weak_promotionz   s    
r+   )"__doc__r   tempfileZ
hypothesisZpytestr#   Znumpy.core._multiarray_testsr   r   r   configurationZset_hypothesis_home_dirpathjoin
gettempdirsettingsZregister_profilelistZHealthCheckdirname__file__Z_pytest_iniZload_profileisfiler
   r   r   Zhookimplr   Zfixturer!   r$   r&   r+   r   r   r   r	   <module>   sR        






