
    ܙd                         d dl Z d dlZd dlmZ d dlZd dlmZmZmZm	Z	 d dl
mZ 	 d dlZdZn# e$ r dZY nw xY wdZ ej        e e          Ze G d d	e                      Zed
k    r ej                     dS dS )    N)dedent)TestCasetemp_directoryoverride_env_configrun_in_subprocess)configTFz*pyyaml needed for configuration file testsc                   L     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Z xZS )

TestConfigFc                     t          d          | _        d| _        t          t          |                                            d S )N
config_tmpi	  )r   tmppathmaxDiffsuperr
   setUp)self	__class__s    7lib/python3.11/site-packages/numba/tests/test_config.pyr   zTestConfig.setUp   s;    %l33j$%%'''''    c                 6    t          j        | j                  S )zT
        Creates a mock launch location.
        Returns the location path.
        )dir)tempfilemkdtempr   )r   s    r   mock_cfg_locationzTestConfig.mock_cfg_location   s    
 DL1111r   c                     t           j                            |t          j                  }t          |d          5 }t          j        ||d           ddd           dS # 1 swxY w Y   dS )z<
        Injects a mock configuration at 'location'
        wtF)default_flow_styleN)ospathjoinr   _config_fnameopenyamldump)r   locationcfgtmpcfgfs        r   inject_mock_cfgzTestConfig.inject_mock_cfg&   s     h(<==&$ 	81Ic17777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   A  A$'A$c                     t                      }t          t                    D ].}|                                rt	          t          |          ||<   /|S )z8
        Gets the current numba config settings
        )dictr   r   isuppergetattr)r   storexs      r   get_settingszTestConfig.get_settings.   sK     V 	. 	.Ayy{{ ."61--ar   c                    t          j                    }|                                 }t          j        |           t	          dd          5  |                                 }ddd           n# 1 swxY w Y   |                     ||           	 t	          dd          5  |                                 }ddd           n# 1 swxY w Y   t          j        |           n# t          j        |           w xY w||fS )z
        Returns a config "original" from a location with no config file
        and then the impact of applying the supplied cfg dictionary as
        a config file at a location in the returned "current".
        _N)r   getcwdr   chdirr   r/   r(   )r   r%   original_cwd
launch_diroriginalcurrents         r   create_config_effectzTestConfig.create_config_effect8   sw    y{{ ++--
 	 !c** 	+ 	+((**H	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	Z---	# %S#.. . .++--. . . . . . . . . . . . . . . H\""""BH\""""  sB   A--A14A1C  C 4C   CC  CC   C6c                    d}t           j        t           j        fD ]}|                      ||          di          \  }}|                     ||k               |                     ||         ||         k               |                     ||         d           |                    |           |                    |           |                     ||           d S )NCOLOR_SCHEMElight_bg)strupperlowerr8   
assertTrueassertEqualpop)r   keycaseorigcurrs        r   test_configzTestConfig.test_configY   s     Y	* 	) 	)D22DDIIz3JKKJD$OODDL)))OODIc2333T#Y
333HHSMMMHHSMMMT4((((	) 	)r   c                 b    |                      i           \  }}|                     ||           d S )N)r8   r@   )r   rD   rE   s      r   test_empty_configzTestConfig.test_empty_configg   s5    ..r22
dt$$$$$r   c                 F   t           j                                        }d|d<   d}d| d}t          t	          |          |          \  }}d}|                     ||                    d                     |                     ||                    d                     d S )	Nnot_a_known_styleNUMBA_CAPTURED_ERRORSzthe source compiledz0from numba import njit
@njit
def foo():
	print('z')
foo())envzMenviron NUMBA_CAPTURED_ERRORS defined but failed to parse 'not_a_known_style'zutf-8)r   environcopyr   r   assertIndecode)r   new_envsource_compiledcodeouterrexpecteds          r   !test_illegal_error_style_handlingz,TestConfig.test_illegal_error_style_handlingl   s    *//##+>'(/5)5 5 5$VD\\w???S,h

7 3 3444oszz'':':;;;;;r   )__name__
__module____qualname___numba_parallel_test_r   r   r(   r/   r8   rF   rH   rW   __classcell__)r   s   @r   r
   r
      s         "( ( ( ( (2 2 28 8 8  ! ! !B) ) )% % %
< < < < < < <r   r
   __main__)r   r   textwrapr   unittestnumba.tests.supportr   r   r   r   
numba.corer   r"   
_HAVE_YAMLImportError	_skip_msgskipIf
needs_yamlr
   rX   main r   r   <module>ri      s:   				        4 4 4 4 4 4 4 4 4 4 4 4      KKKJJ   JJJ 9	X_^Y77
 c< c< c< c< c< c< c< c<L zHMOOOOO s   - 77