
    J/Ph                        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lm	Z	 d dl
mZ d dlmZ d dlmc mZ  G d	 d
e          Z G d de          Z G d de          Z G d de          Zedk    r ej                     dS dS )    N)
skipUnless)NonCallableMock)chain)datetime)redirect_stdout)StringIO)TestCasec                   @     e Zd Z fdZ fdZd Zd Zd Zd Z xZ	S )TestSysInfoc                 |   t          t          |                                            t          j                    | _        t          t          j        ft          t          j	        ft          t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        f
t*          t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        f	t>          t          j         t          j!        ftD          t          j#        ftH          t          j%        t          j&        fi| _'        tQ          | j'        )                                 | _*        d S N)+superr   setUpnsiget_sysinfoinfoint
_cpu_countfloat_runtimestr_machine	_cpu_name_platform_name_os_name_os_version_python_comp_python_impl_python_version_llvm_version_numpy_versionbool_cu_dev_init_svml_state_svml_loaded_svml_operational_llvm_svml_patched_tbb_thread_openmp_thread_wkq_thread_numpy_AVX512_SKX_detectedlist_errors	_warningsdict_numba_env_varsr   _start
_start_utcsafe_contentsr   values	safe_keysself	__class__s    X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_sysinfo.pyr   zTestSysInfo.setUp   s.   k4  &&(((O%%	  "  #!"   %&".
  # 
K)
T  2 9 9 ; ;<    c                 Z    t          t          |                                            | `d S r   )r   r   tearDownr   r6   s    r9   r<   zTestSysInfo.tearDown?   s(    k4  ))+++IIIr:   c                     | j         D ]K}|                     |          5  |                     || j                   d d d            n# 1 swxY w Y   Ld S N)k)r5   subTestassertInr   )r7   r?   s     r9   test_has_safe_keyszTestSysInfo.test_has_safe_keysD   s     	, 	,A"" , ,a+++, , , , , , , , , , , , , , ,	, 	,s   AA	A	c                     | j                                         D ]Y\  }}|D ]Q}|                     |          5  |                     | j        |         |           d d d            n# 1 swxY w Y   RZd S r>   )r3   itemsr@   assertIsInstancer   r7   tkeysr?   s       r9   test_safe_content_typez"TestSysInfo.test_safe_content_typeI   s    )//11 	; 	;GAt ; ;\\A\&& ; ;))$)A,:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;	; 	;   "A''A+.A+c                 Z    |                      | j        t          j                            d S r   )assertFalser   r   r-   r7   s    r9   test_has_no_errorzTestSysInfo.test_has_no_errorO   s%    3;/00000r:   c                     t                      }t          |          5  t          j        i           }d d d            n# 1 swxY w Y   |                     |           |                                 d S r   )r   r   r   display_sysinfoassertIsNoneclose)r7   outputress      r9   test_display_empty_infoz#TestSysInfo.test_display_empty_infoR   s    V$$ 	* 	*%b))C	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*#s   ?AA)
__name__
__module____qualname__r   r<   rB   rI   rN   rU   __classcell__r8   s   @r9   r   r      s        -= -= -= -= -=^    
, , ,
; ; ;1 1 1      r:   r   c                        e Zd ZdZdZddgZ fdZ fdZd Zd Z	 e
 ej                    d	v d
          d             Z xZS )TestSysInfoWithPsutili    i         c                    t          t          |                                            t          j        | _        dt          _        t                      t          _        t          j        j        j	        }| j
        |_        | j        |_        t          j                    dv r(t          j        j        j	        }| j        |j        _	        nd t          j        j        _	        t          j        t          j                              | _        d S )NTLinuxWindows)r   r\   r   r   _psutil_importpsutil_orig_stater   psutilvirtual_memoryreturn_value	mem_totaltotalmem_available	availableplatformsystemProcess	cpus_listcpu_affinityget_os_spec_infor   )r7   vmprocr8   s      r9   r   zTestSysInfoWithPsutil.setUp`   s    #T**00222!$!3!$&&
Z&3>)? 555:%2D-1^D**.2CJ+():):;;			r:   c                 x    t          t          |                                            | j        t          _        d S r   )r   r\   r<   rd   r   rc   r6   s    r9   r<   zTestSysInfoWithPsutil.tearDownr   s1    #T**33555!3r:   c                 B   t           j        t           j        f}|D ]}|                     |          5  |                     || j                                                   |                     | j        |         t                     d d d            n# 1 swxY w Y   d S r>   	r   
_mem_total_mem_availabler@   rA   r   rH   rE   r   r7   rH   r?   s      r9   test_has_all_dataz'TestSysInfoWithPsutil.test_has_all_datav        23 	9 	9A"" 9 9a!1!1222%%dilC8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9   ABB	B	c                     |                      | j        t          j                 | j                   |                      | j        t          j                 | j                   d S r   )assertEqualr   r   rw   rh   rx   rj   rM   s    r9   test_has_correct_valuesz-TestSysInfoWithPsutil.test_has_correct_values}   sL    3>2DNCCC3#568JKKKKKr:   r`   z5CPUs allowed info only available on Linux and Windowsc                    |                      | j        t          j                 t	          | j                             |                      | j        t          j                 d                    d | j        D                                  d S )N c              3   4   K   | ]}t          |          V  d S r   )r   ).0ns     r9   	<genexpr>z7TestSysInfoWithPsutil.test_cpus_list.<locals>.<genexpr>   s(      !A!AQ#a&&!A!A!A!A!A!Ar:   )r~   r   r   _cpus_allowedlenro   
_cpus_listjoinrM   s    r9   test_cpus_listz$TestSysInfoWithPsutil.test_cpus_list   s     	3#45s4>7J7JKKK3>2!A!A$.!A!A!AAA	C 	C 	C 	C 	Cr:   )rV   rW   rX   rh   rj   ro   r   r<   rz   r   r   rl   rm   r   rY   rZ   s   @r9   r\   r\   Z   s        IMAI< < < < <$4 4 4 4 49 9 9L L L Z!!%99GI IC CI IC C C C Cr:   r\   c                   .     e Zd Z fdZ fdZd Z xZS )TestSysInfoWithoutPsutilc                     t          t          |                                            t          j        | _        dt          _        t          j        t          j                              | _	        d S )NF)
r   r   r   r   rc   rd   rq   rl   rm   r   r6   s    r9   r   zTestSysInfoWithoutPsutil.setUp   sQ    &--33555!$!3"():):;;			r:   c                 x    t          t          |                                            | j        t          _        d S r   )r   r   r<   rd   r   rc   r6   s    r9   r<   z!TestSysInfoWithoutPsutil.tearDown   s1    &--66888!3r:   c                 B   t           j        t           j        f}|D ]}|                     |          5  |                     || j                                                   |                     | j        |         t                     d d d            n# 1 swxY w Y   d S r>   rv   ry   s      r9   rz   z*TestSysInfoWithoutPsutil.test_has_all_data   r{   r|   )rV   rW   rX   r   r<   rz   rY   rZ   s   @r9   r   r      s`        < < < < <4 4 4 4 49 9 9 9 9 9 9r:   r   c                        e Zd Zd Zd Zd ZdS )TestPlatformSpecificInfoc                 >   t           t          j        fit           t          j        fit           t          j        fid| _        t          j                    | _        | j                            | j        i           | _	        t          j
        | j                  | _        d S )N)ra   rb   Darwin)r   r   _libc_version_os_spec_versionplat_spec_inforl   rm   os_namegetcontentsrq   r   rM   s    r9   r   zTestPlatformSpecificInfo.setUp   s     c') c*, c*,

 

  ((+//bAA(66			r:   c                    t          | j                                         }|D ]]}|                     |          5  |                     || j                                                   d d d            n# 1 swxY w Y   ^d S r>   )r   r   r4   r@   rA   r   rH   ry   s      r9   rz   z*TestPlatformSpecificInfo.test_has_all_data   s    dm**,,- 	3 	3A"" 3 3a!1!12223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3s   .A55A9	<A9	c                     | j                                         D ]Y\  }}|D ]Q}|                     |          5  |                     | j        |         |           d d d            n# 1 swxY w Y   RZd S r>   )r   rD   r@   rE   r   rF   s       r9   test_content_typez*TestPlatformSpecificInfo.test_content_type   s    }**,, 	; 	;GAt ; ;\\A\&& ; ;))$)A,:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;;	; 	;rJ   N)rV   rW   rX   r   rz   r    r:   r9   r   r      sA        7 7 7 3 3 3; ; ; ; ;r:   r   __main__)rl   unittestr   unittest.mockr   	itertoolsr   r   
contextlibr   ior   numba.tests.supportr	   numba.misc.numba_sysinfomiscnumba_sysinfor   r   r\   r   r   rV   mainr   r:   r9   <module>r      s           ) ) ) ) ) )             & & & & & &       ( ( ( ( ( ( & & & & & & & & &I I I I I( I I IX,C ,C ,C ,C ,CH ,C ,C ,C^9 9 9 9 9x 9 9 9(; ; ; ; ;x ; ; ;> zHMOOOOO r:   