
    xKg                         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.                          yy)    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        j0                  t        j2                  t        j4                  t        j6                  t        j8                  t        j:                  t        j<                  f	t>        t        j@                  t        jB                  ftD        t        jF                  ftH        t        jJ                  t        jL                  fi| _'        tQ        | jN                  jS                          | _*        y 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    \/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_sysinfo.pyr   zTestSysInfo.setUp   s[   k4&(OO%	  ""    ##!!""     %%&&""..
  ## 

K)
T  2 2 9 9 ;<    c                 .    t         t        |           | `y r   )r   r   tearDownr   r6   s    r9   r<   zTestSysInfo.tearDown?   s    k4)+Ir:   c                     | j                   D ]9  }| j                  |      5  | j                  || j                         d d d        ; y # 1 sw Y   FxY wN)k)r5   subTestassertInr   )r7   r?   s     r9   test_has_safe_keyszTestSysInfo.test_has_safe_keysD   s?    A"a+ #"  ""s   A

A	c                     | j                   j                         D ]F  \  }}|D ]<  }| j                  |      5  | j                  | j                  |   |       d d d        > H y # 1 sw Y   KxY wr>   )r3   itemsr@   assertIsInstancer   r7   tkeysr?   s       r9   test_safe_content_typez"TestSysInfo.test_safe_content_typeI   s^    ))//1GAt\\A\&))$))A,: '&  2&&    A%%A.c                 \    | j                  | j                  t        j                            y r   )assertFalser   r   r-   r7   s    r9   test_has_no_errorzTestSysInfo.test_has_no_errorO   s    3;;/0r:   c                     t               }t        |      5  t        j                  i       }d d d        | j	                         |j                          y # 1 sw Y   +xY wr   )r   r   r   display_sysinfoassertIsNoneclose)r7   outputress      r9   test_display_empty_infoz#TestSysInfo.test_display_empty_infoR   sF    V$%%b)C %# %$s   AA)
__name__
__module____qualname__r   r<   rB   rI   rN   rU   __classcell__r8   s   @r9   r   r      s"    -=^
,
;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                               | _        y )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2!$!3!3!$&
ZZ&&33>>))?? 55::%%22D-1^^D*.2CJJ+(():;	r:   c                 T    t         t        |           | j                  t        _        y r   )r   r\   r<   rd   r   rc   r6   s    r9   r<   zTestSysInfoWithPsutil.tearDownr   s    #T35!33r:   c                 :   t         j                  t         j                  f}|D ]j  }| j                  |      5  | j	                  || j
                  j                                | j                  | j
                  |   t               d d d        l y # 1 sw Y   wxY w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   n     2 23A"a!12%%diilC8 #" ""   ABB	c                     | j                  | j                  t        j                     | j                         | j                  | j                  t        j
                     | j                         y r   )assertEqualr   r   rw   rh   rx   rj   rM   s    r9   test_has_correct_valuesz-TestSysInfoWithPsutil.test_has_correct_values}   sH    3>>2DNNC3#5#568J8JKr:   r`   z5CPUs allowed info only available on Linux and Windowsc                    | j                  | j                  t        j                     t	        | j
                               | j                  | j                  t        j                     dj                  d | j
                  D                     y )N c              3   2   K   | ]  }t        |        y wr   )r   ).0ns     r9   	<genexpr>z7TestSysInfoWithPsutil.test_cpus_list.<locals>.<genexpr>   s     !A.Q#a&.s   )r~   r   r   _cpus_allowedlenro   
_cpus_listjoinrM   s    r9   test_cpus_listz$TestSysInfoWithPsutil.test_cpus_list   s`     	3#4#45s4>>7JK3>>2!A$..!AA	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9L !%99GICI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                               | _	        y )NF)
r   r   r   r   rc   rd   rq   rl   rm   r   r6   s    r9   r   zTestSysInfoWithoutPsutil.setUp   s@    &35!$!3!3"(():;	r:   c                 T    t         t        |           | j                  t        _        y r   )r   r   r<   rd   r   rc   r6   s    r9   r<   z!TestSysInfoWithoutPsutil.tearDown   s    &68!33r:   c                 :   t         j                  t         j                  f}|D ]j  }| j                  |      5  | j	                  || j
                  j                                | j                  | j
                  |   t               d d d        l y # 1 sw Y   wxY w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9r:   r   c                       e Zd Zd Zd Zd Zy)TestPlatformSpecificInfoc                 h   t         t        j                  fit         t        j                  fit         t        j                  fid| _        t        j                         | _        | j                  j                  | j                  i       | _	        t        j                  | j                        | _        y )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((6	r:   c                     t        | j                  j                          }|D ]G  }| j                  |      5  | j	                  || j
                  j                                d d d        I y # 1 sw Y   TxY wr>   )r   r   r4   r@   rA   r   rH   ry   s      r9   rz   z*TestPlatformSpecificInfo.test_has_all_data   sY    dmm**,-A"a!12 #" ""s   +A..A7	c                     | j                   j                         D ]F  \  }}|D ]<  }| j                  |      5  | j                  | j                  |   |       d d d        > H y # 1 sw Y   KxY w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      s    7 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      sv       )   &  ( & &I( IX,CH ,C^9x 9(;x ;> zHMMO r:   